diff --git a/README.html b/README.html index b5d6cf7..b5fd3f5 100644 --- a/README.html +++ b/README.html @@ -9,7 +9,7 @@
-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?
My multitasking library for lua
To install copy the multi folder into your enviroment and you are good to go
It is a pure lua binding if you ingore the integrations and the love2d compat
If you find any bugs or have any issues please let me know :)
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?
My multitasking library for lua
To install copy the multi folder into your enviroment and you are good to go
It is a pure lua binding if you ingore the integrations and the love2d compat
If you find any bugs or have any issues please let me know :)
Note: the queuer still does not work as expected!
Ring ring!!!
1
2
3
4
5
6
7
8
9
10
Done
Done
1
2
3
4
5
6
7
8
9
10
Ring ring!!!
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.
Expected OutputNote: the queuer still does not work as expected!
Ring ring!!!
1
2
3
4
5
6
7
8
9
10
Done
Actual Output
Done
1
2
3
4
5
6
7
8
9
10
Ring ring!!!
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.
_require=require -- lets play with the require method a bit
-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
+
">require("multi")
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")
count=0
@@ -1058,7 +1046,8 @@ loop:OnTimedOut(function<
end
end)
multi:mainloop()
-Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Loop timed out! tloop Trying again…
Looping…
Looping…
Looping…
Looping…
Looping…
We did it! 1 2 3
Updated from 1.8.1 to 1.8.2
Added:
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Looping…
Loop timed out! tloop Trying again…
Looping…
Looping…
Looping…
Looping…
Looping…
We did it! 1 2 3
Updated from 1.8.2 to 1.8.3
Added:
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.
* 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
Added:
The threaded table is setup just like the threaded queue.
It provids GLOBAL like features without having to write to GLOBAL!
This is useful for module creators who want to keep their data private, but also use GLOBAL like coding.
It has a few features that makes it a bit better than plain ol GLOBAL (For now…)
(ThreadedTable - TT for short)
we also have the “sync” method, this one was made for love2d because we do a syncing trick to get data in a table format. The lanes side has a sync method as well so no worries. Using indexing calls sync once and may grab your variable. This allows you to have the lanes indexing ‘like’ syntax when doing regular indexing in love2d side of the module. As of right now both sides work flawlessly! And this effect is now the GLOBAL as well
On GLOBALS sync is a internal method for keeping the GLOBAL table in order. You can still use sThread.waitFor(name) to wait for variables that may of may not yet exist!
Time for some examples:
Changes
-------
+Updated from 1.8.2 to 1.8.3
+Added:
+**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
Added:
- 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!
diff --git a/multi/init.lua b/multi/init.lua
index cbd74b3..3bd3e8d 100644
--- a/multi/init.lua
+++ b/multi/init.lua
@@ -45,8 +45,8 @@ function print(...)
end
end
multi = {}
-multi.Version="1.8.2"
-multi._VERSION="1.8.2"
+multi.Version="1.8.3"
+multi._VERSION="1.8.3"
multi.stage='stable'
multi.__index = multi
multi.Mainloop={}
@@ -978,7 +978,106 @@ function multi:mainloop()
else
return "Already Running!"
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
function multi._tFunc(self,dt)
for i=1,#self.Tasks do
diff --git a/rockspecs/multi-1.8-3.rockspec b/rockspecs/multi-1.8-3.rockspec
new file mode 100644
index 0000000..88088ad
--- /dev/null
+++ b/rockspecs/multi-1.8-3.rockspec
@@ -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"
+ }
+}
\ No newline at end of file