Updated to (1.8.3)
Added new mainloop Options to increase the speed of the program
This commit is contained in:
parent
8557f2d3f8
commit
6863704352
21
README.html
21
README.html
File diff suppressed because one or more lines are too long
26
README.md
26
README.md
@ -1,4 +1,4 @@
|
|||||||
# multi Version: 1.8.2 (More support for love & lanes threading!)
|
# multi Version: 1.8.3 (Performance Increase! Check changes for info)
|
||||||
**Note: The changes section has information on how to use the new features as they come out. Why put the infomation twice on the readme?**</br>
|
**Note: The changes section has information on how to use the new features as they come out. Why put the infomation twice on the readme?**</br>
|
||||||
|
|
||||||
My multitasking library for lua</br>
|
My multitasking library for lua</br>
|
||||||
@ -537,13 +537,7 @@ Threads
|
|||||||
-------
|
-------
|
||||||
These fix the hold problem that you get with regular objects, and they work exactly the same! They even have some extra features that make them really useful.</br>
|
These fix the hold problem that you get with regular objects, and they work exactly the same! They even have some extra features that make them really useful.</br>
|
||||||
```lua
|
```lua
|
||||||
_require=require -- lets play with the require method a bit
|
require("multi")
|
||||||
function require(path)
|
|
||||||
path=path:gsub("%*","all")
|
|
||||||
_require(path)
|
|
||||||
end
|
|
||||||
require("multi.*") -- now I can use that lovely * symbol to require everything
|
|
||||||
-- Pointless I know I... Don't look at me like that :P
|
|
||||||
test=multi:newThreadedProcess("main") -- you can thread processors and all Actors see note for a list of actors you can thread!
|
test=multi:newThreadedProcess("main") -- you can thread processors and all Actors see note for a list of actors you can thread!
|
||||||
test2=multi:newThreadedProcess("main2")
|
test2=multi:newThreadedProcess("main2")
|
||||||
count=0
|
count=0
|
||||||
@ -791,6 +785,22 @@ We did it! 1 2 3</br>
|
|||||||
|
|
||||||
Changes
|
Changes
|
||||||
-------
|
-------
|
||||||
|
Updated from 1.8.2 to 1.8.3</br>
|
||||||
|
Added:</br>
|
||||||
|
**New Mainloop functions** Below you can see the slight differences... Function overhead is not too bad in lua, but has a real difference. multi:mainloop() and multi:unprotectedMainloop() use the same algorithm yet the dedicated unprotected one is slightly faster due to having less function overhead.
|
||||||
|
- multi:mainloop()\* -- Bench: 16830003 Steps in 3 second(s)!
|
||||||
|
- multi:protectedMainloop() -- Bench: 16699308 Steps in 3 second(s)!
|
||||||
|
- multi:unprotectedMainloop() -- Bench: 16976627 Steps in 3 second(s)!
|
||||||
|
- multi:prioritizedMainloop1() -- Bench: 15007133 Steps in 3 second(s)!
|
||||||
|
- multi:prioritizedMainloop2() -- Bench: 15526248 Steps in 3 second(s)!
|
||||||
|
|
||||||
|
\* The OG mainloop function remains the same and old methods to achieve what we have with the new ones still exist
|
||||||
|
|
||||||
|
These new methods help by removing function overhead that is caused through the original mainloop function. The one downside is that you no longer have the flexiblity to change the processing during runtime.
|
||||||
|
|
||||||
|
However there is a work around! You can use processes to run multiobjs as well and use the other methods on them.
|
||||||
|
|
||||||
|
I may make a full comparison between each method and which is faster, but for now trust that the dedicated ones with less function overhead are infact faster. Not by much but still faster. :D
|
||||||
Updated from 1.8.1 to 1.8.2</br>
|
Updated from 1.8.1 to 1.8.2</br>
|
||||||
Added:</br>
|
Added:</br>
|
||||||
- multi:newsystemThreadedTable(name) NOTE: Metatables are not supported in transfers. However there is a work around obj:init() that you see does this. Take a look in the multi/integration/shared/shared.lua files to see how I did it!
|
- multi:newsystemThreadedTable(name) NOTE: Metatables are not supported in transfers. However there is a work around obj:init() that you see does this. Take a look in the multi/integration/shared/shared.lua files to see how I did it!
|
||||||
|
|||||||
105
multi/init.lua
105
multi/init.lua
@ -45,8 +45,8 @@ function print(...)
|
|||||||
end
|
end
|
||||||
end
|
end
|
||||||
multi = {}
|
multi = {}
|
||||||
multi.Version="1.8.2"
|
multi.Version="1.8.3"
|
||||||
multi._VERSION="1.8.2"
|
multi._VERSION="1.8.3"
|
||||||
multi.stage='stable'
|
multi.stage='stable'
|
||||||
multi.__index = multi
|
multi.__index = multi
|
||||||
multi.Mainloop={}
|
multi.Mainloop={}
|
||||||
@ -978,7 +978,106 @@ function multi:mainloop()
|
|||||||
else
|
else
|
||||||
return "Already Running!"
|
return "Already Running!"
|
||||||
end
|
end
|
||||||
--print("Did you call multi:Stop()? This method should not be used when using multi:mainloop() unless of course you wanted to stop it! you can restart the multi, by using multi:reboot() and calling multi:mainloop() again or by using multi:uManager()")
|
end
|
||||||
|
function multi:protectedMainloop()
|
||||||
|
if not multi.isRunning then
|
||||||
|
multi.isRunning=true
|
||||||
|
for i=1,#self.Tasks do
|
||||||
|
self.Tasks[i](self)
|
||||||
|
end
|
||||||
|
rawset(self,'Start',self.clock())
|
||||||
|
while self.Active do
|
||||||
|
self:Do_Order()
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "Already Running!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function multi:unprotectedMainloop()
|
||||||
|
if not multi.isRunning then
|
||||||
|
multi.isRunning=true
|
||||||
|
for i=1,#self.Tasks do
|
||||||
|
self.Tasks[i](self)
|
||||||
|
end
|
||||||
|
rawset(self,'Start',self.clock())
|
||||||
|
while self.Active do
|
||||||
|
local Loop=self.Mainloop
|
||||||
|
_G.ID=0
|
||||||
|
for _D=#Loop,1,-1 do
|
||||||
|
if Loop[_D] then
|
||||||
|
if Loop[_D].Active then
|
||||||
|
Loop[_D].Id=_D
|
||||||
|
self.CID=_D
|
||||||
|
Loop[_D]:Act()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "Already Running!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function multi:prioritizedMainloop1()
|
||||||
|
if not multi.isRunning then
|
||||||
|
multi.isRunning=true
|
||||||
|
for i=1,#self.Tasks do
|
||||||
|
self.Tasks[i](self)
|
||||||
|
end
|
||||||
|
rawset(self,'Start',self.clock())
|
||||||
|
while self.Active do
|
||||||
|
local Loop=self.Mainloop
|
||||||
|
_G.ID=0
|
||||||
|
local PS=self
|
||||||
|
for _D=#Loop,1,-1 do
|
||||||
|
if Loop[_D] then
|
||||||
|
if (PS.PList[PS.PStep])%Loop[_D].Priority==0 then
|
||||||
|
if Loop[_D].Active then
|
||||||
|
Loop[_D].Id=_D
|
||||||
|
self.CID=_D
|
||||||
|
Loop[_D]:Act()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
PS.PStep=PS.PStep+1
|
||||||
|
if PS.PStep>7 then
|
||||||
|
PS.PStep=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "Already Running!"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
function multi:prioritizedMainloop2()
|
||||||
|
if not multi.isRunning then
|
||||||
|
multi.isRunning=true
|
||||||
|
for i=1,#self.Tasks do
|
||||||
|
self.Tasks[i](self)
|
||||||
|
end
|
||||||
|
rawset(self,'Start',self.clock())
|
||||||
|
while self.Active do
|
||||||
|
local Loop=self.Mainloop
|
||||||
|
_G.ID=0
|
||||||
|
local PS=self
|
||||||
|
for _D=#Loop,1,-1 do
|
||||||
|
if Loop[_D] then
|
||||||
|
if (PS.PStep)%Loop[_D].Priority==0 then
|
||||||
|
if Loop[_D].Active then
|
||||||
|
Loop[_D].Id=_D
|
||||||
|
self.CID=_D
|
||||||
|
Loop[_D]:Act()
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
PS.PStep=PS.PStep+1
|
||||||
|
if PS.PStep>self.Priority_Idle then
|
||||||
|
PS.PStep=1
|
||||||
|
end
|
||||||
|
end
|
||||||
|
else
|
||||||
|
return "Already Running!"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
function multi._tFunc(self,dt)
|
function multi._tFunc(self,dt)
|
||||||
for i=1,#self.Tasks do
|
for i=1,#self.Tasks do
|
||||||
|
|||||||
30
rockspecs/multi-1.8-3.rockspec
Normal file
30
rockspecs/multi-1.8-3.rockspec
Normal file
@ -0,0 +1,30 @@
|
|||||||
|
package = "multi"
|
||||||
|
version = "1.8-3"
|
||||||
|
source = {
|
||||||
|
url = "git://github.com/rayaman/multi.git",
|
||||||
|
tag = "v1.8.3",
|
||||||
|
}
|
||||||
|
description = {
|
||||||
|
summary = "Lua Multi tasking library",
|
||||||
|
detailed = [[
|
||||||
|
This library contains many methods for multi tasking. From simple side by side code using multiobjs, to using coroutine based Threads and System threads(When you have lua lanes installed or are using love2d. Optional) The core of the library works on lua 5.1+ however the systemthreading features are limited to 5.1
|
||||||
|
]],
|
||||||
|
homepage = "https://github.com/rayaman/multi",
|
||||||
|
license = "MIT"
|
||||||
|
}
|
||||||
|
dependencies = {
|
||||||
|
"lua >= 5.1, < 5.2"
|
||||||
|
}
|
||||||
|
build = {
|
||||||
|
type = "builtin",
|
||||||
|
modules = {
|
||||||
|
-- Note the required Lua syntax when listing submodules as keys
|
||||||
|
["multi.init"] = "multi/init.lua",
|
||||||
|
["multi.all"] = "multi/all.lua",
|
||||||
|
["multi.compat.backwards[1,5,0]"] = "multi/compat/backwards[1,5,0].lua",
|
||||||
|
["multi.compat"] = "multi/compat/love2d.lua",
|
||||||
|
["multi.integration.lanesManager"] = "multi/integration/lanesManager.lua",
|
||||||
|
["multi.integration.loveManager"] = "multi/integration/loveManager.lua",
|
||||||
|
["multi.integration.shared.shared"] = "multi/integration/shared/shared.lua"
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user