diff --git a/README.html b/README.html index ebfca4b..b305f3d 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? Also I added a Testing Branch. That Branch will have the latest updates, but those updates may be unstable. I like to keep the master as bug free as possible
In Changes you’ll find documentation for(In Order):
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? Also I added a Testing Branch. That Branch will have the latest updates, but those updates may be unstable. I like to keep the master as bug free as possible
In Changes you’ll find documentation for(In Order):
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 :)
If you don’t see a table of contents try using the ReadMe.html file. It is eaiser to navigate the readme
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
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
Added:
Allows the execution of system calls without hold up. It is possible to do the same using io.popen()! You decide which works best for you!
local GLOBAL,sThread=require("multi.integration.lanesManager").init()
+cmd=multi:newSystemThreadedExecute("SystemThreadedExecuteTest.lua") -- This file is important!
+cmd.OnCMDFinished(function(code) -- callback function to grab the exit code... Called when the command goes through
+ print("Got Code: "..code)
+end)
+multi:newTLoop(function()
+ print("...") -- lets show that we aren't being held up
+end,1)
+multi:mainloop()
+Added:
First you need to create the object
This works the same way as love2d as it does with lanes… It is getting increasing harder to make both work the same way with speed in mind… Anyway…
"
c.thread=love.thread.newThread(multi.integration.love2d.ThreadBase:gsub("INSERT_USER_CODE",dump(func)))
- c.thread:start(c.ID)
+ c.thread:start(c.ID,c.name)
function c:kill()
multi.integration.GLOBAL["__DIEPLZ"..self.ID.."__"]="__DIEPLZ"..self.ID.."__"
end
diff --git a/examples/love2d Threading Example/multi/integration/shared/shared.lua b/examples/love2d Threading Example/multi/integration/shared/shared.lua
index 92a1b44..e754fc1 100644
--- a/examples/love2d Threading Example/multi/integration/shared/shared.lua
+++ b/examples/love2d Threading Example/multi/integration/shared/shared.lua
@@ -21,6 +21,14 @@ 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.
]]
+function multi.randomString(n)
+ local str = ''
+ local strings = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z','1','2','3','4','5','6','7','8','9','0','A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'}
+ for i=1,n do
+ str = str..''..strings[math.random(1,#strings)]
+ end
+ return str
+end
function multi:newSystemThreadedQueue(name) -- in love2d this will spawn a channel on both ends
local c={} -- where we will store our object
c.name=name -- set the name this is important for the love2d side
@@ -262,8 +270,8 @@ if love then
self.queueOUT:push({self.jobnum,name,...})
self.jobnum=self.jobnum+1
end
- local GLOBAL=multi.integration.GLOBAL -- set up locals incase we are using lanes
- local sThread=multi.integration.THREAD -- set up locals incase we are using lanes
+ local GLOBAL=multi.integration.GLOBAL
+ local sThread=multi.integration.THREAD
GLOBAL["__JQ_COUNT__"]=c.cores
for i=1,c.cores do
multi:newSystemThread("System Threaded Job Queue Worker Thread #"..i,function()
@@ -305,3 +313,31 @@ if love then
end
end
end
+function multi:newSystemThreadedExecute(cmd)
+ local c={}
+ local GLOBAL=multi.integration.GLOBAL -- set up locals incase we are using lanes
+ local sThread=multi.integration.THREAD -- set up locals incase we are using lanes
+ local name="Execute_Thread"..multi.randomString(16)
+ c.name=name
+ GLOBAL[name.."CMD"]=cmd
+ multi:newSystemThread(name,function()
+ if love then -- lets make sure we don't reference upvalues if using love2d
+ GLOBAL=_G.GLOBAL
+ sThread=_G.sThread
+ name=__THREADNAME__ -- global data same as the name we used in this functions creation
+ end -- Lanes should take the local upvalues ^^^
+ cmd=sThread.waitFor(name.."CMD")
+ local ret=os.execute(cmd)
+ GLOBAL[name.."R"]=ret
+ end)
+ c.OnCMDFinished=multi:newConnection()
+ c.looper=multi:newLoop(function(self)
+ local ret=GLOBAL[self.link.name.."R"]
+ if ret then
+ self.link.OnCMDFinished:Fire(ret)
+ self:Destroy()
+ end
+ end)
+ c.looper.link=c
+ return c
+end
diff --git a/multi/init.lua b/multi/init.lua
index feadba6..2349735 100644
--- a/multi/init.lua
+++ b/multi/init.lua
@@ -45,9 +45,9 @@ function print(...)
end
end
multi = {}
-multi.Version="1.8.4"
-multi._VERSION="1.8.4"
-multi.stage='stable'
+multi.Version="1.8.5"
+multi._VERSION="1.8.5"
+multi.stage='mostly-stable'
multi.__index = multi
multi.Mainloop={}
multi.Tasks={}