diff --git a/README.html b/README.html index 0d85ba6..ce01703 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 intergrations 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 :)
For real-time assistance with my libraries! A place where you can ask questions and get help with any of my libraries. Also you can request features and stuff there as well.
https://discord.gg/U8UspuA
In regards to intergrations, thread cancellation works slightly different for love2d and lanes. Within love2d I was unable to (To lazy to…) not use the multi library within the thread. A fix for this is to call multi:Stop() when you are done with your threaded code! This may change however if I find a way to work around this. In love2d in order to mimic the GLOBAL table I needed the library to constantly sync tha data… You can use the sThread.waitFor(varname), or sThread.hold(func) methods to sync the globals, to get the value instead of using GLOBAL and this could work. If you want to go this route I suggest setting multi.isRunning=true to prevent the auto runner from doing its thing! This will make the multi manager no longer function, but thats the point :P
Add system threads for love2d that works like the lanesManager (loveManager, slight differences).In regards to integrations, thread cancellation works slightly different for love2d and lanes. Within love2d I was unable to (To lazy to…) not use the multi library within the thread. A fix for this is to call multi:Stop() when you are done with your threaded code! This may change however if I find a way to work around this. In love2d in order to mimic the GLOBAL table I needed the library to constantly sync tha data… You can use the sThread.waitFor(varname), or sThread.hold(func) methods to sync the globals, to get the value instead of using GLOBAL and this could work. If you want to go this route I suggest setting multi.isRunning=true to prevent the auto runner from doing its thing! This will make the multi manager no longer function, but thats the point :P
-- Basic usage Alarms: Have been moved to the core of the library require("multi") would work as well
require("multi") -- gets the entire library
alarm=multi:newAlarm(3) -- in seconds can go to .001 uses the built in os.clock()
@@ -192,7 +192,7 @@ alarm:OnRing(functionprint("3 Seconds have passed!")
a:Reset(n) -- if n were nil it will reset back to 3, or it would reset to n seconds
end)
-multi:mainloop() -- the main loop of the program, multi:umanager() exists as well to allow intergration in other loops Ex: love2d love.update function. More on this binding in the wiki!
+multi:mainloop() -- the main loop of the program, multi:umanager() exists as well to allow integration in other loops Ex: love2d love.update function. More on this binding in the wiki!
The library is modular so you only need to require what you need to. Because of this, the global enviroment is altered
There are many useful objects that you can use
Check out the wiki for detailed usage, but here are the objects:
We already showed alarms in action so lets move on to a Loop object
Throughout these examples I am going to do some strange things in order to show other features of the library!
functionprint("You broke me :(")
end)
multi:mainloop()
-Loop #1!
Loop #2!
Loop #3!
Loop #4!
Loop #5!
Loop #6!
Loop #7!
Loop #8!
Loop #9!
Loop #10!
You broke me :(
With loops out of the way lets go down the line
This library aims to be Async like. In reality everything is still on one thread unless you are using the lanes intergration module WIP (More on that later)
OutputLoop #1!
Loop #2!
Loop #3!
Loop #4!
Loop #5!
Loop #6!
Loop #7!
Loop #8!
Loop #9!
Loop #10!
You broke me :(
With loops out of the way lets go down the line
This library aims to be Async like. In reality everything is still on one thread unless you are using the lanes integration module WIP (More on that later)
EVENTS
function<
end)
multi:mainloop()
Output (Change the value inc as indicated in the comment to see the outcomes!)
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
Changes
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/intergration/shared/shared.lua files to see how I did it!
- Modified the GLOBAL metatable to sync before doing its tests
- multi._VERSION was multi.Version, felt it would be more consistant this way… I left the old way of getting the version just incase someone has used that way. It will eventually be gone. Also multi:getVersion() will do the job just as well and keep your code nice and update related bug free!
- Also everything that is included in the: multi/intergration/shared/shared.lua (Which is loaded automatically) works in both lanes and love2d enviroments!
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)
+- 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!
- Modified the GLOBAL metatable to sync before doing its tests
- multi._VERSION was multi.Version, felt it would be more consistant this way… I left the old way of getting the version just incase someone has used that way. It will eventually be gone. Also multi:getVersion() will do the job just as well and keep your code nice and update related bug free!
- Also everything that is included in the: multi/integration/shared/shared.lua (Which is loaded automatically) works in both lanes and love2d enviroments!
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)
- TT:waitFor(name)
- TT:sync()
- TT[“var”]=value
- print(TT[“var”])
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:
Using multi:newSystemThreadedTable(name)
-- lanes Desktop lua! NOTE: this is in lanesintergratetest6.lua in the examples folder
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
test=multi:newSystemThreadedTable("YO"):init()
test["test1"]="lol"
multi:newSystemThread("test",function()
@@ -1081,7 +1081,7 @@ multi:newThread("test2",-- love2d gaming lua! NOTE: this is in main4.lua in the love2d examples
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
require("core.GuiManager")
gui.ff.Color=Color.Black
test=multi:newSystemThreadedTable("YO"):init()
@@ -1119,16 +1119,16 @@ multi:newThread("test2","no done yet!",0,0,300,100)
t:centerX()
t:centerY()
-
Updated from 1.8.0 to 1.8.1
No real change!
Changed the structure of the library. Combined the coroutine based threads into the core!
Only compat and intergrations are not part of the core and never will be by nature.
This should make the library more convient to use.
I left multi/all.lua file so if anyone had libraries/projects that used that it will still work!
Updated from 1.7.6 to 1.8.0
(How much thread could a thread thread if a thread could thread thread?)
Added:
-- multi:newSystemThreadedQueue()
- multi:systemThreadedBenchmark()
- More example files
- multi:canSystemThread() — true if an intergration was added false otherwise (For module creation)
- Fixed a few bugs in the loveManager
Using multi:systemThreadedBenchmark()
Using multi:systemThreadedBenchmark()package.path="?/init.lua;"..package.path
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
multi:systemThreadedBenchmark(3):OnBench(function(self,count)
print("First Bench: "..count)
multi:systemThreadedBenchmark(3,"All Threads: ")
@@ -1136,7 +1136,7 @@ multi:systemThreadedBenchmark(3):OnBench(
Using multi:newSystemThreadedQueue()
Quick Note: queues shared across multiple objects will be pulling from the same “queue” keep this in mind when coding! Also the queue respects direction a push on the thread side cannot be popped on the thread side… Same goes for the mainthread!
-- in love2d, this file will be in the same example folder as before, but is named main2.lua
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
@@ -1267,8 +1267,8 @@ t=gui:newTextLabel("no done yet!",In Lanes-- The code is compatible with each other, I just wanted to show different things you can do in both examples
--- This file can be found in the examples folder as lanesintergrationtest4.lua
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+-- This file can be found in the examples folder as lanesintegrationtest4.lua
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
queue=multi:newSystemThreadedQueue("QUEUE"):init()
queue:push("This is a test")
queue:push("This is a test2")
@@ -1324,9 +1324,9 @@ multi:newThread("test!",end
end)
multi:mainloop()
-
Updated from 1.7.5 to 1.7.6
Fixed:
Typos like always
Added:
multi:getPlatform() — returns “love2d” if using the love2d platform or returns “lanes” if using lanes for threading
examples files
In Events added method setTask(func)
The old way still works and is more convient to be honest, but I felt a method to do this was ok.
Updated:
some example files to reflect changes to the core. Changes allow for less typing
loveManager to require the compat if used so you don’t need 2 require line to retrieve the library
Updated from 1.7.4 to 1.7.5
Fixed some typos in the readme… (I am sure there are more there are always more)
Added more features for module support
TODO:
Work on performance of the library… I see 3 places where I can make this thing run quicker
I’ll show case some old versions of the multitasking library eventually so you can see its changes in days past!
Updated from 1.7.3 to 1.7.4
Added: the example folder which will be populated with more examples in the near future!
The loveManager intergration that mimics the lanesManager intergration almost exactly to keep coding in both enviroments as close to possible. This is done mostly for library creation support!
An example of the loveManager in action using almost the same code as the lanesintergreationtest2.lua
NOTE: This code has only been tested to work on love2d version 1.10.2 thoough it should work version 0.9.0
require("core.Library") -- Didn't add this to a repo yet! Will do eventually... Allows for injections and other cool things
require("multi.compat.love2d") -- allows for multitasking and binds my libraies to the love2d engine that i am using
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
@@ -1464,7 +1464,7 @@ GLOBAL["Bench"]=3"no done yet!",0,0,300,100)
t:centerX()
t:centerY()
-
Updated from 1.7.2 to 1.7.3
Changed how requiring the library works!
require("multi.all") Will still work as expected; however, with the exception of threading, compat, and intergrations everything else has been moved into the core of the library.
Will still work as expected; however, with the exception of threading, compat, and integrations everything else has been moved into the core of the library.require
("multi.step")
require("multi.task")
-- ^ they are all part of the core now
-
Updated from 1.7.1 to 1.7.2
Moved updaters, loops, and alarms into the init.lua file. I consider them core features and they are referenced in the init.lua file so they need to exist there. Threaded versions are still separate though. Added another example file
Updated from 1.7.0 to 1.7.1 Bug fixes only
Updated from 1.6.0 to 1.7.0
Modified: multi.intergration.lanesManager.lua
It is now in a stable and simple state Works with the latest lanes version! Tested with version 3.11 I cannot promise that everything will work with eariler versions. Future versions are good though.
Example Usage:
sThread is a handle to a global interface for system threads to interact with themself
thread is the interface for multithreads as seen in the threading section
GLOBAL a table that can be used throughout each and every thread
sThreads have a few methods
sThread.set(name,val) — you can use the GLOBAL table instead modifies the same table anyway
sThread.get(name) — you can use the GLOBAL table instead modifies the same table anyway
sThread.waitFor(name) — waits until a value exists, if it does it returns it
sThread.getCores() — returns the number of cores on your cpu
sThread.sleep(n) — sleeps for a bit stopping the entire thread from running
sThread.hold(n) — sleeps until a condition is met
local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+
">local GLOBAL,sThread=require("multi.integration.lanesManager").init()
require("multi.all")
multi:newAlarm(2):OnRing(function(self)
GLOBAL["NumOfCores"]=sThread.getCores()
@@ -1530,7 +1530,7 @@ multi:newAlarm(13):OnRing("FinalTest"]=true
end)
multi:newSystemThread("test",function() -- spawns a thread in another lua process
- require("multi.all") -- now you can do all of your coding with the multi library! You could even spawn more threads from here with the intergration. You would need to require the interaction again though
+ require("multi.all") -- now you can do all of your coding with the multi library! You could even spawn more threads from here with the integration. You would need to require the interaction again though
print("Waiting for variable: NumOfCores")
print("Got it: ",sThread.waitFor("NumOfCores"))
sThread.hold(function()
diff --git a/README.md b/README.md
index ef14937..55019e4 100644
--- a/README.md
+++ b/README.md
@@ -4,7 +4,7 @@
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 intergrations and the love2d compat
+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 :)
@@ -27,13 +27,13 @@ Planned features/TODO
- [ ] sThread.wrap(obj) **May or may not be completed** Theory: Allows interaction in one thread to affect it in another. The addition to threaded tables may make this possible!
- [ ] SystemThreaded Actors -- After some tests i figured out a way to make this work... It will work slightly different though. This is due to the actor needing to be splittable...
- [ ] LoadBalancing for system threads (Once SystemThreaded Actors are done)
-- [ ] Add more intergrations
+- [ ] Add more integrations
- [ ] Finish the wiki stuff. (11% done)
- [ ] Test for unknown bugs
Known Bugs/Issues
-----------------
-In regards to intergrations, thread cancellation works slightly different for love2d and lanes. Within love2d I was unable to (To lazy to...) not use the multi library within the thread. A fix for this is to call `multi:Stop()` when you are done with your threaded code! This may change however if I find a way to work around this. In love2d in order to mimic the GLOBAL table I needed the library to constantly sync tha data... You can use the sThread.waitFor(varname), or sThread.hold(func) methods to sync the globals, to get the value instead of using GLOBAL and this could work. If you want to go this route I suggest setting multi.isRunning=true to prevent the auto runner from doing its thing! This will make the multi manager no longer function, but thats the point :P
+In regards to integrations, thread cancellation works slightly different for love2d and lanes. Within love2d I was unable to (To lazy to...) not use the multi library within the thread. A fix for this is to call `multi:Stop()` when you are done with your threaded code! This may change however if I find a way to work around this. In love2d in order to mimic the GLOBAL table I needed the library to constantly sync tha data... You can use the sThread.waitFor(varname), or sThread.hold(func) methods to sync the globals, to get the value instead of using GLOBAL and this could work. If you want to go this route I suggest setting multi.isRunning=true to prevent the auto runner from doing its thing! This will make the multi manager no longer function, but thats the point :P
Usage:
-----
@@ -45,7 +45,7 @@ alarm:OnRing(function(a)
print("3 Seconds have passed!")
a:Reset(n) -- if n were nil it will reset back to 3, or it would reset to n seconds
end)
-multi:mainloop() -- the main loop of the program, multi:umanager() exists as well to allow intergration in other loops Ex: love2d love.update function. More on this binding in the wiki!
+multi:mainloop() -- the main loop of the program, multi:umanager() exists as well to allow integration in other loops Ex: love2d love.update function. More on this binding in the wiki!
```
The library is modular so you only need to require what you need to. Because of this, the global enviroment is altered
@@ -117,7 +117,7 @@ You broke me :(
With loops out of the way lets go down the line
-This library aims to be Async like. In reality everything is still on one thread *unless you are using the lanes intergration module WIP* (More on that later)
+This library aims to be Async like. In reality everything is still on one thread *unless you are using the lanes integration module WIP* (More on that later)
EVENTS
------
@@ -788,10 +788,10 @@ Changes
-------
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/intergration/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!
- Modified the GLOBAL metatable to sync before doing its tests
- multi._VERSION was multi.Version, felt it would be more consistant this way... I left the old way of getting the version just incase someone has used that way. It will eventually be gone. Also multi:getVersion() will do the job just as well and keep your code nice and update related bug free!
-- Also everything that is included in the: multi/intergration/shared/shared.lua (Which is loaded automatically) works in both lanes and love2d enviroments!
+- Also everything that is included in the: multi/integration/shared/shared.lua (Which is loaded automatically) works in both lanes and love2d enviroments!
The threaded table is setup just like the threaded queue.
It provids GLOBAL like features without having to write to GLOBAL!
@@ -811,7 +811,7 @@ Time for some examples:
# Using multi:newSystemThreadedTable(name)
```lua
-- lanes Desktop lua! NOTE: this is in lanesintergratetest6.lua in the examples folder
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
test=multi:newSystemThreadedTable("YO"):init()
test["test1"]="lol"
multi:newSystemThread("test",function()
@@ -829,7 +829,7 @@ multi:mainloop()
```lua
-- love2d gaming lua! NOTE: this is in main4.lua in the love2d examples
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
require("core.GuiManager")
gui.ff.Color=Color.Black
test=multi:newSystemThreadedTable("YO"):init()
@@ -852,7 +852,7 @@ t:centerY()
Updated from 1.8.0 to 1.8.1
No real change!
Changed the structure of the library. Combined the coroutine based threads into the core!
-Only compat and intergrations are not part of the core and never will be by nature.
+Only compat and integrations are not part of the core and never will be by nature.
This should make the library more convient to use.
I left multi/all.lua file so if anyone had libraries/projects that used that it will still work!
Updated from 1.7.6 to 1.8.0 (How much thread could a thread thread if a thread could thread thread?)
@@ -860,13 +860,13 @@ Added:
- multi:newSystemThreadedQueue()
- multi:systemThreadedBenchmark()
- More example files
-- multi:canSystemThread() -- true if an intergration was added false otherwise (For module creation)
+- multi:canSystemThread() -- true if an integration was added false otherwise (For module creation)
- Fixed a few bugs in the loveManager
# Using multi:systemThreadedBenchmark()
```lua
package.path="?/init.lua;"..package.path
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
multi:systemThreadedBenchmark(3):OnBench(function(self,count)
print("First Bench: "..count)
multi:systemThreadedBenchmark(3,"All Threads: ")
@@ -879,7 +879,7 @@ Quick Note: queues shared across multiple objects will be pulling from the same
```lua
-- in love2d, this file will be in the same example folder as before, but is named main2.lua
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
@@ -947,8 +947,8 @@ t:centerY()
# In Lanes
```lua
-- The code is compatible with each other, I just wanted to show different things you can do in both examples
--- This file can be found in the examples folder as lanesintergrationtest4.lua
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+-- This file can be found in the examples folder as lanesintegrationtest4.lua
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
queue=multi:newSystemThreadedQueue("QUEUE"):init()
queue:push("This is a test")
queue:push("This is a test2")
@@ -998,13 +998,13 @@ I'll show case some old versions of the multitasking library eventually so you c
Updated from 1.7.3 to 1.7.4
Added: the example folder which will be populated with more examples in the near future!
-The loveManager intergration that mimics the lanesManager intergration almost exactly to keep coding in both enviroments as close to possible. This is done mostly for library creation support!
+The loveManager integration that mimics the lanesManager integration almost exactly to keep coding in both enviroments as close to possible. This is done mostly for library creation support!
An example of the loveManager in action using almost the same code as the lanesintergreationtest2.lua
NOTE: This code has only been tested to work on love2d version 1.10.2 thoough it should work version 0.9.0
```lua
require("core.Library") -- Didn't add this to a repo yet! Will do eventually... Allows for injections and other cool things
require("multi.compat.love2d") -- allows for multitasking and binds my libraies to the love2d engine that i am using
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
@@ -1075,7 +1075,7 @@ t:centerY()
```
Updated from 1.7.2 to 1.7.3
Changed how requiring the library works!
-`require("multi.all")` Will still work as expected; however, with the exception of threading, compat, and intergrations everything else has been moved into the core of the library.
+`require("multi.all")` Will still work as expected; however, with the exception of threading, compat, and integrations everything else has been moved into the core of the library.
```lua
-- This means that these are no longer required and will cause an error if done so
require("multi.loop")
@@ -1095,7 +1095,7 @@ Moved updaters, loops, and alarms into the init.lua file. I consider them core f
Updated from 1.7.0 to 1.7.1 Bug fixes only
Updated from 1.6.0 to 1.7.0
-Modified: multi.intergration.lanesManager.lua
+Modified: multi.integration.lanesManager.lua
It is now in a stable and simple state Works with the latest lanes version! Tested with version 3.11 I cannot promise that everything will work with eariler versions. Future versions are good though.
Example Usage:
sThread is a handle to a global interface for system threads to interact with themself
@@ -1111,7 +1111,7 @@ sThread.getCores() -- returns the number of cores on your cpu
sThread.sleep(n) -- sleeps for a bit stopping the entire thread from running
sThread.hold(n) -- sleeps until a condition is met
```lua
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
require("multi.all")
multi:newAlarm(2):OnRing(function(self)
GLOBAL["NumOfCores"]=sThread.getCores()
@@ -1123,7 +1123,7 @@ multi:newAlarm(13):OnRing(function(self)
GLOBAL["FinalTest"]=true
end)
multi:newSystemThread("test",function() -- spawns a thread in another lua process
- require("multi.all") -- now you can do all of your coding with the multi library! You could even spawn more threads from here with the intergration. You would need to require the interaction again though
+ require("multi.all") -- now you can do all of your coding with the multi library! You could even spawn more threads from here with the integration. You would need to require the interaction again though
print("Waiting for variable: NumOfCores")
print("Got it: ",sThread.waitFor("NumOfCores"))
sThread.hold(function()
diff --git a/examples/lanes resource loading/resourceloading.lua b/examples/lanes resource loading/resourceloading.lua
index 309dc1e..8cc8a81 100644
--- a/examples/lanes resource loading/resourceloading.lua
+++ b/examples/lanes resource loading/resourceloading.lua
@@ -1,4 +1,4 @@
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
require("proAudioRt") -- an audio library
-- The hosting site with precompiled binaries is down, but here is a link to a archive
-- https://web.archive.org/web/20160907180559/http://viremo.eludi.net:80/proteaAudio/proteaaudiolua.html documentation and downloads are availiable... I also have saved copies just in case :D
diff --git a/examples/lanesintergratetest.lua b/examples/lanesintergratetest.lua
index d8f2a37..820385c 100644
--- a/examples/lanesintergratetest.lua
+++ b/examples/lanesintergratetest.lua
@@ -1,5 +1,5 @@
package.path="?/init.lua;?.lua;"..package.path
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
multi:newAlarm(2):OnRing(function(self)
GLOBAL["NumOfCores"]=sThread.getCores()
end)
diff --git a/examples/lanesintergratetest2.lua b/examples/lanesintergratetest2.lua
index 095a7cd..ecaf091 100644
--- a/examples/lanesintergratetest2.lua
+++ b/examples/lanesintergratetest2.lua
@@ -1,5 +1,5 @@
package.path="?/init.lua;?.lua;"..package.path
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init() -- loads the lanesManager and includes the entire multi library
+local GLOBAL,sThread=require("multi.integration.lanesManager").init() -- loads the lanesManager and includes the entire multi library
local function comma_value(amount)
local formatted = amount
while true do
diff --git a/examples/lanesintergratetest3.lua b/examples/lanesintergratetest3.lua
index bf1f585..e83d6f5 100644
--- a/examples/lanesintergratetest3.lua
+++ b/examples/lanesintergratetest3.lua
@@ -1,5 +1,5 @@
package.path="?/init.lua;?.lua;"..package.path -- Spawing threads using 1 method and the sThread.getCores() function!
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init() -- loads the lanesManager and includes the entire multi library
+local GLOBAL,sThread=require("multi.integration.lanesManager").init() -- loads the lanesManager and includes the entire multi library
local function comma_value(amount)
local formatted = amount
while true do
diff --git a/examples/lanesintergratetest4.lua b/examples/lanesintergratetest4.lua
index 34a651c..40be2c4 100644
--- a/examples/lanesintergratetest4.lua
+++ b/examples/lanesintergratetest4.lua
@@ -1,4 +1,4 @@
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
queue=multi:newSystemThreadedQueue("QUEUE"):init()
queue:push("This is a test")
queue:push("This is a test2")
diff --git a/examples/lanesintergratetest5.lua b/examples/lanesintergratetest5.lua
index ecd7d3c..7e0898a 100644
--- a/examples/lanesintergratetest5.lua
+++ b/examples/lanesintergratetest5.lua
@@ -1,5 +1,5 @@
package.path="?/init.lua;"..package.path -- slightly different usage of the code
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
queue=multi:newSystemThreadedQueue("QUEUE")
queue:push(1)
queue:push(2)
diff --git a/examples/lanesintergratetest6.lua b/examples/lanesintergratetest6.lua
index 4a893fb..5b7443c 100644
--- a/examples/lanesintergratetest6.lua
+++ b/examples/lanesintergratetest6.lua
@@ -1,5 +1,5 @@
-- lanes Desktop lua! NOTE: this is in lanesintergratetest6.lua in the examples folder
-local GLOBAL,sThread=require("multi.intergration.lanesManager").init()
+local GLOBAL,sThread=require("multi.integration.lanesManager").init()
test=multi:newSystemThreadedTable("YO"):init()
test["test1"]="lol"
multi:newSystemThread("test",function()
diff --git a/examples/love2d Threading Example/main.lua b/examples/love2d Threading Example/main.lua
index 57c210d..8ed71a6 100644
--- a/examples/love2d Threading Example/main.lua
+++ b/examples/love2d Threading Example/main.lua
@@ -1,5 +1,5 @@
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
diff --git a/examples/love2d Threading Example/main2.lua b/examples/love2d Threading Example/main2.lua
index 9528b5f..f049404 100644
--- a/examples/love2d Threading Example/main2.lua
+++ b/examples/love2d Threading Example/main2.lua
@@ -1,5 +1,5 @@
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
diff --git a/examples/love2d Threading Example/main3.lua b/examples/love2d Threading Example/main3.lua
index 1593f44..c025a66 100644
--- a/examples/love2d Threading Example/main3.lua
+++ b/examples/love2d Threading Example/main3.lua
@@ -1,5 +1,5 @@
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
--IMPORTANT
-- Do not make the above local, this is the one difference that the lanesManager does not have
-- If these are local the functions will have the upvalues put into them that do not exist on the threaded side
diff --git a/examples/love2d Threading Example/main4.lua b/examples/love2d Threading Example/main4.lua
index 3106b09..b12e7a5 100644
--- a/examples/love2d Threading Example/main4.lua
+++ b/examples/love2d Threading Example/main4.lua
@@ -1,5 +1,5 @@
require("core.Library")
-GLOBAL,sThread=require("multi.intergration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
+GLOBAL,sThread=require("multi.integration.loveManager").init() -- load the love2d version of the lanesManager and requires the entire multi library
require("core.GuiManager")
gui.ff.Color=Color.Black
test=multi:newSystemThreadedTable("YO"):init()
diff --git a/examples/love2d Threading Example/multi/intergration/lanesManager.lua b/examples/love2d Threading Example/multi/integration/lanesManager.lua
similarity index 100%
rename from examples/love2d Threading Example/multi/intergration/lanesManager.lua
rename to examples/love2d Threading Example/multi/integration/lanesManager.lua
diff --git a/examples/love2d Threading Example/multi/intergration/loveManager.lua b/examples/love2d Threading Example/multi/integration/loveManager.lua
similarity index 100%
rename from examples/love2d Threading Example/multi/intergration/loveManager.lua
rename to examples/love2d Threading Example/multi/integration/loveManager.lua
diff --git a/examples/love2d Threading Example/multi/intergration/shared/shared.lua b/examples/love2d Threading Example/multi/integration/shared/shared.lua
similarity index 100%
rename from examples/love2d Threading Example/multi/intergration/shared/shared.lua
rename to examples/love2d Threading Example/multi/integration/shared/shared.lua
diff --git a/examples/love2d Threading Example/multi/threading.lua b/examples/love2d Threading Example/multi/threading.lua
deleted file mode 100644
index 4c0397a..0000000
--- a/examples/love2d Threading Example/multi/threading.lua
+++ /dev/null
@@ -1,181 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi")
-thread={}
-multi.GlobalVariables={}
-if os.getOS()=="windows" then
- thread.__CORES=tonumber(os.getenv("NUMBER_OF_PROCESSORS"))
-else
- thread.__CORES=tonumber(io.popen("nproc --all"):read("*n"))
-end
-function thread.sleep(n)
- coroutine.yield({"_sleep_",n})
-end
-function thread.hold(n)
- coroutine.yield({"_hold_",n})
-end
-function thread.skip(n)
- coroutine.yield({"_skip_",n})
-end
-function thread.kill()
- coroutine.yield({"_kill_",":)"})
-end
-function thread.yeild()
- coroutine.yield({"_sleep_",0})
-end
-function thread.getCores()
- return thread.__CORES
-end
-function thread.set(name,val)
- multi.GlobalVariables[name]=val
- return true
-end
-function thread.get(name)
- return multi.GlobalVariables[name]
-end
-function thread.waitFor(name)
- thread.hold(function() return thread.get(name)~=nil end)
- return thread.get(name)
-end
-function thread.testFor(name,val,sym)
- thread.hold(function() return thread.get(name)~=nil end)
- return thread.get(name)
-end
-function multi:newTBase(ins)
- local c = {}
- c.Active=true
- c.func={}
- c.ender={}
- c.Id=0
- c.PId=0
- c.Parent=self
- c.held=false
- return c
-end
-function multi:newThread(name,func)
- local c={}
- c.ref={}
- c.Name=name
- c.thread=coroutine.create(func)
- c.sleep=1
- c.firstRunDone=false
- c.timer=multi.scheduler:newTimer()
- c.ref.Globals=self:linkDomain("Globals")
- function c.ref:send(name,val)
- ret=coroutine.yield({Name=name,Value=val})
- self:syncGlobals(ret)
- end
- function c.ref:get(name)
- return self.Globals[name]
- end
- function c.ref:kill()
- err=coroutine.yield({"_kill_"})
- if err then
- error("Failed to kill a thread! Exiting...")
- end
- end
- function c.ref:sleep(n)
- if type(n)=="function" then
- ret=coroutine.yield({"_hold_",n})
- self:syncGlobals(ret)
- elseif type(n)=="number" then
- n = tonumber(n) or 0
- ret=coroutine.yield({"_sleep_",n})
- self:syncGlobals(ret)
- else
- error("Invalid Type for sleep!")
- end
- end
- function c.ref:syncGlobals(v)
- self.Globals=v
- end
- table.insert(self:linkDomain("Threads"),c)
- if not multi.scheduler:isActive() then
- multi.scheduler:Resume()
- end
-end
-multi:setDomainName("Threads")
-multi:setDomainName("Globals")
-multi.scheduler=multi:newUpdater()
-multi.scheduler.Type="scheduler"
-function multi.scheduler:setStep(n)
- self.skip=tonumber(n) or 24
-end
-multi.scheduler.skip=0
-multi.scheduler.counter=0
-multi.scheduler.Threads=multi:linkDomain("Threads")
-multi.scheduler.Globals=multi:linkDomain("Globals")
-multi.scheduler:OnUpdate(function(self)
- self.counter=self.counter+1
- for i=#self.Threads,1,-1 do
- ret={}
- if coroutine.status(self.Threads[i].thread)=="dead" then
- table.remove(self.Threads,i)
- else
- if self.Threads[i].timer:Get()>=self.Threads[i].sleep then
- if self.Threads[i].firstRunDone==false then
- self.Threads[i].firstRunDone=true
- self.Threads[i].timer:Start()
- _,ret=coroutine.resume(self.Threads[i].thread,self.Threads[i].ref)
- else
- _,ret=coroutine.resume(self.Threads[i].thread,self.Globals)
- end
- if ret==true or ret==false then
- print("Thread Ended!!!")
- ret={}
- end
- end
- if ret then
- if ret[1]=="_kill_" then
- table.remove(self.Threads,i)
- elseif ret[1]=="_sleep_" then
- self.Threads[i].timer:Reset()
- self.Threads[i].sleep=ret[2]
- elseif ret[1]=="_skip_" then
- self.Threads[i].timer:Reset()
- self.Threads[i].sleep=math.huge
- local event=multi:newEvent(function(evnt) return multi.scheduler.counter>=evnt.counter end)
- event.link=self.Threads[i]
- event.counter=self.counter+ret[2]
- event:OnEvent(function(evnt)
- evnt.link.sleep=0
- end)
- elseif ret[1]=="_hold_" then
- self.Threads[i].timer:Reset()
- self.Threads[i].sleep=math.huge
- local event=multi:newEvent(ret[2])
- event.link=self.Threads[i]
- event:OnEvent(function(evnt)
- evnt.link.sleep=0
- end)
- elseif ret.Name then
- self.Globals[ret.Name]=ret.Value
- end
- end
- end
- end
-end)
-multi.scheduler:setStep()
-multi.scheduler:Pause()
-multi.OnError=multi:newConnection()
diff --git a/examples/love2d Threading Example/multi/threading/alarm.lua b/examples/love2d Threading Example/multi/threading/alarm.lua
deleted file mode 100644
index 0b10c7c..0000000
--- a/examples/love2d Threading Example/multi/threading/alarm.lua
+++ /dev/null
@@ -1,73 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedAlarm(name,set)
- local c=self:newTBase()
- c.Type='alarmThread'
- c.timer=self:newTimer()
- c.set=set or 0
- function c:tofile(path)
- local m=bin.new()
- m:addBlock(self.Type)
- m:addBlock(self.set)
- m:addBlock(self.Active)
- m:tofile(path)
- end
- function c:Resume()
- self.rest=false
- self.timer:Resume()
- end
- function c:Reset(n)
- if n then self.set=n end
- self.rest=false
- self.timer:Reset(n)
- end
- function c:OnRing(func)
- table.insert(self.func,func)
- end
- function c:Pause()
- self.timer:Pause()
- self.rest=true
- end
- c.rest=false
- c.updaterate=multi.Priority_Low -- skips
- c.restRate=0 -- secs
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- thread.sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- if c.timer:Get()>=c.set then
- c:Pause()
- for i=1,#c.func do
- c.func[i](c)
- end
- end
- thread.skip(c.updaterate) -- lets rest a bit
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/all.lua b/examples/love2d Threading Example/multi/threading/all.lua
deleted file mode 100644
index fe05cb4..0000000
--- a/examples/love2d Threading Example/multi/threading/all.lua
+++ /dev/null
@@ -1,7 +0,0 @@
-require("multi.threading.step")
-require("multi.threading.tstep")
-require("multi.threading.updater")
-require("multi.threading.alarm")
-require("multi.threading.loop")
-require("multi.threading.event")
-require("multi.threading.process")
diff --git a/examples/love2d Threading Example/multi/threading/event.lua b/examples/love2d Threading Example/multi/threading/event.lua
deleted file mode 100644
index b8fc6ed..0000000
--- a/examples/love2d Threading Example/multi/threading/event.lua
+++ /dev/null
@@ -1,66 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedEvent(name,task)
- local c=self:newTBase()
- c.Type='eventThread'
- c.Task=task or function() end
- function c:OnEvent(func)
- table.insert(self.func,func)
- end
- function c:tofile(path)
- local m=bin.new()
- m:addBlock(self.Type)
- m:addBlock(self.Task)
- m:addBlock(self.func)
- m:addBlock(self.Active)
- m:tofile(path)
- end
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- c.rest=false
- c.updaterate=0
- c.restRate=1
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- ref:sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- if c.Task(self) then
- for _E=1,#c.func do
- c.func[_E](c)
- end
- c:Pause()
- end
- ref:sleep(c.updaterate) -- lets rest a bit
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/loop.lua b/examples/love2d Threading Example/multi/threading/loop.lua
deleted file mode 100644
index 175fd80..0000000
--- a/examples/love2d Threading Example/multi/threading/loop.lua
+++ /dev/null
@@ -1,65 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedLoop(name,func)
- local c=self:newTBase()
- c.Type='loopThread'
- c.Start=os.clock()
- if func then
- c.func={func}
- end
- function c:tofile(path)
- local m=bin.new()
- m:addBlock(self.Type)
- m:addBlock(self.func)
- m:addBlock(self.Active)
- m:tofile(path)
- end
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- function c:OnLoop(func)
- table.insert(self.func,func)
- end
- c.rest=false
- c.updaterate=0
- c.restRate=.75
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- thread.sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- for i=1,#c.func do
- c.func[i](os.clock()-self.Start,c)
- end
- thread.sleep(c.updaterate) -- lets rest a bit
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/process.lua b/examples/love2d Threading Example/multi/threading/process.lua
deleted file mode 100644
index 99c3b51..0000000
--- a/examples/love2d Threading Example/multi/threading/process.lua
+++ /dev/null
@@ -1,106 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedProcess(name)
- local c = {}
- setmetatable(c, multi)
- function c:newBase(ins)
- local ct = {}
- setmetatable(ct, self.Parent)
- ct.Active=true
- ct.func={}
- ct.ender={}
- ct.Id=0
- ct.PId=0
- ct.Act=function() end
- ct.Parent=self
- ct.held=false
- ct.ref=self.ref
- table.insert(self.Mainloop,ct)
- return ct
- end
- c.Parent=self
- c.Active=true
- c.func={}
- c.Id=0
- c.Type='process'
- c.Mainloop={}
- c.Tasks={}
- c.Tasks2={}
- c.Garbage={}
- c.Children={}
- c.Paused={}
- c.Active=true
- c.Id=-1
- c.Rest=0
- c.updaterate=.01
- c.restRate=.1
- c.Jobs={}
- c.queue={}
- c.jobUS=2
- c.rest=false
- function c:getController()
- return nil
- end
- function c:Start()
- self.rest=false
- end
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- function c:Remove()
- self.ref:kill()
- end
- function c:kill()
- err=coroutine.yield({"_kill_"})
- if err then
- error("Failed to kill a thread! Exiting...")
- end
- end
- function c:sleep(n)
- if type(n)=="function" then
- ret=coroutine.yield({"_hold_",n})
- elseif type(n)=="number" then
- n = tonumber(n) or 0
- ret=coroutine.yield({"_sleep_",n})
- else
- error("Invalid Type for sleep!")
- end
- end
- c.hold=c.sleep
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- ref:Sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- c:uManager()
- ref:sleep(c.updaterate) -- lets rest a bit
- end
- end
- end)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/step.lua b/examples/love2d Threading Example/multi/threading/step.lua
deleted file mode 100644
index e69543a..0000000
--- a/examples/love2d Threading Example/multi/threading/step.lua
+++ /dev/null
@@ -1,115 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedStep(name,start,reset,count,skip)
- local c=self:newTBase()
- local think=1
- c.Type='stepThread'
- c.pos=start or 1
- c.endAt=reset or math.huge
- c.skip=skip or 0
- c.spos=0
- c.count=count or 1*think
- c.funcE={}
- c.funcS={}
- c.start=start or 1
- if start~=nil and reset~=nil then
- if start>reset then
- think=-1
- end
- end
- function c:tofile(path)
- local m=bin.new()
- m:addBlock(self.Type)
- m:addBlock(self.func)
- m:addBlock(self.funcE)
- m:addBlock(self.funcS)
- m:addBlock({pos=self.pos,endAt=self.endAt,skip=self.skip,spos=self.spos,count=self.count,start=self.start})
- m:addBlock(self.Active)
- m:tofile(path)
- end
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- c.Reset=c.Resume
- function c:OnStart(func)
- table.insert(self.funcS,func)
- end
- function c:OnStep(func)
- table.insert(self.func,1,func)
- end
- function c:OnEnd(func)
- table.insert(self.funcE,func)
- end
- function c:Break()
- self.rest=true
- end
- function c:Update(start,reset,count,skip)
- self.start=start or self.start
- self.endAt=reset or self.endAt
- self.skip=skip or self.skip
- self.count=count or self.count
- self:Resume()
- end
- c.updaterate=0
- c.restRate=.1
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- ref:sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- if c~=nil then
- if c.spos==0 then
- if c.pos==c.start then
- for fe=1,#c.funcS do
- c.funcS[fe](c)
- end
- end
- for i=1,#c.func do
- c.func[i](c.pos,c)
- end
- c.pos=c.pos+c.count
- if c.pos-c.count==c.endAt then
- c:Pause()
- for fe=1,#c.funcE do
- c.funcE[fe](c)
- end
- c.pos=c.start
- end
- end
- end
- c.spos=c.spos+1
- if c.spos>=c.skip then
- c.spos=0
- end
- ref:sleep(c.updaterate) -- lets rest a bit
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/tloop.lua b/examples/love2d Threading Example/multi/threading/tloop.lua
deleted file mode 100644
index aa438be..0000000
--- a/examples/love2d Threading Example/multi/threading/tloop.lua
+++ /dev/null
@@ -1,65 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedTLoop(name,func,n)
- local c=self:newTBase()
- c.Type='tloopThread'
- c.restN=n or 1
- if func then
- c.func={func}
- end
- function c:tofile(path)
- local m=bin.new()
- m:addBlock(self.Type)
- m:addBlock(self.func)
- m:addBlock(self.Active)
- m:tofile(path)
- end
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- function c:OnLoop(func)
- table.insert(self.func,func)
- end
- c.rest=false
- c.updaterate=0
- c.restRate=.75
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- thread.sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- for i=1,#c.func do
- c.func[i](c)
- end
- thread.sleep(c.restN) -- lets rest a bit
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/tstep.lua b/examples/love2d Threading Example/multi/threading/tstep.lua
deleted file mode 100644
index 34bc226..0000000
--- a/examples/love2d Threading Example/multi/threading/tstep.lua
+++ /dev/null
@@ -1,114 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedTStep(name,start,reset,count,set)
- local c=self:newTBase()
- local think=1
- c.Type='tstepThread'
- c.Priority=self.Priority_Low
- c.start=start or 1
- local reset = reset or math.huge
- c.endAt=reset
- c.pos=start or 1
- c.skip=skip or 0
- c.count=count or 1*think
- c.funcE={}
- c.timer=os.clock()
- c.set=set or 1
- c.funcS={}
- function c:Update(start,reset,count,set)
- self.start=start or self.start
- self.pos=self.start
- self.endAt=reset or self.endAt
- self.set=set or self.set
- self.count=count or self.count or 1
- self.timer=os.clock()
- self:Resume()
- end
- function c:tofile(path)
- local m=bin.new()
- m:addBlock(self.Type)
- m:addBlock(self.func)
- m:addBlock(self.funcE)
- m:addBlock(self.funcS)
- m:addBlock({pos=self.pos,endAt=self.endAt,skip=self.skip,timer=self.timer,count=self.count,start=self.start,set=self.set})
- m:addBlock(self.Active)
- m:tofile(path)
- end
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- function c:OnStart(func)
- table.insert(self.funcS,func)
- end
- function c:OnStep(func)
- table.insert(self.func,func)
- end
- function c:OnEnd(func)
- table.insert(self.funcE,func)
- end
- function c:Break()
- self.Active=nil
- end
- function c:Reset(n)
- if n then self.set=n end
- self.timer=os.clock()
- self:Resume()
- end
- c.updaterate=0--multi.Priority_Low -- skips
- c.restRate=0
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- thread.sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- if os.clock()-c.timer>=c.set then
- c:Reset()
- if c.pos==c.start then
- for fe=1,#c.funcS do
- c.funcS[fe](c)
- end
- end
- for i=1,#c.func do
- c.func[i](c.pos,c)
- end
- c.pos=c.pos+c.count
- if c.pos-c.count==c.endAt then
- c:Pause()
- for fe=1,#c.funcE do
- c.funcE[fe](c)
- end
- c.pos=c.start
- end
- end
- thread.skip(c.updaterate) -- lets rest a bit
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/examples/love2d Threading Example/multi/threading/updater.lua b/examples/love2d Threading Example/multi/threading/updater.lua
deleted file mode 100644
index e87e78e..0000000
--- a/examples/love2d Threading Example/multi/threading/updater.lua
+++ /dev/null
@@ -1,55 +0,0 @@
---[[
-MIT License
-
-Copyright (c) 2017 Ryan Ward
-
-Permission is hereby granted, free of charge, to any person obtaining a copy
-of this software and associated documentation files (the "Software"), to deal
-in the Software without restriction, including without limitation the rights
-to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
-copies of the Software, and to permit persons to whom the Software is
-furnished to do so, subject to the following conditions:
-
-The above copyright notice and this permission notice shall be included in all
-copies or substantial portions of the Software.
-
-THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
-IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
-FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
-AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
-LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
-OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
-SOFTWARE.
-]]
-require("multi.threading")
-function multi:newThreadedUpdater(name,skip)
- local c=self:newTBase()
- c.Type='updaterThread'
- c.pos=1
- c.skip=skip or 1
- function c:Resume()
- self.rest=false
- end
- function c:Pause()
- self.rest=true
- end
- c.OnUpdate=self.OnMainConnect
- c.rest=false
- c.updaterate=0
- c.restRate=.75
- multi:newThread(name,function(ref)
- while true do
- if c.rest then
- thread.sleep(c.restRate) -- rest a bit more when a thread is paused
- else
- for i=1,#c.func do
- c.func[i](c)
- end
- c.pos=c.pos+1
- thread.skip(c.skip)
- end
- end
- end)
- self:create(c)
- return c
-end
diff --git a/multi/intergration/lanesManager.lua b/multi/integration/lanesManager.lua
similarity index 100%
rename from multi/intergration/lanesManager.lua
rename to multi/integration/lanesManager.lua
diff --git a/multi/intergration/loveManager.lua b/multi/integration/loveManager.lua
similarity index 100%
rename from multi/intergration/loveManager.lua
rename to multi/integration/loveManager.lua
diff --git a/multi/intergration/shared/shared.lua b/multi/integration/shared/shared.lua
similarity index 100%
rename from multi/intergration/shared/shared.lua
rename to multi/integration/shared/shared.lua