diff --git a/README.html b/README.html
index c461431..ebfca4b 100644
--- a/README.html
+++ b/README.html
@@ -9,7 +9,7 @@
-multi Version: 1.8.4 (System Threaded Job Queues)
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):
+multi Version: 1.8.4 (System Threaded Job Queues)
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
Note SystemThreadedTable’s behavior is not stable! I am looking into this.
In Changes you’ll find documentation for(In Order):
- System Threaded Job Queues
- New mainloop functions
- System Threaded Tables
- System Threaded Benchmark
- System Threaded Queues
- Threading related features
- And backwards compat stuff
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
-
diff --git a/README.md b/README.md
index f231ca5..e8340a0 100644
--- a/README.md
+++ b/README.md
@@ -1,6 +1,8 @@
# multi Version: 1.8.4 (System Threaded Job Queues)
**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
+# Note SystemThreadedTable's behavior is not stable! I am looking into this.
+
In Changes you'll find documentation for(In Order):
- System Threaded Job Queues
- New mainloop functions
diff --git a/SystemThreadedExecuteTest.lua b/SystemThreadedExecuteTest.lua
new file mode 100644
index 0000000..2b830d3
--- /dev/null
+++ b/SystemThreadedExecuteTest.lua
@@ -0,0 +1,6 @@
+package.path="?/init.lua;"..package.path
+require("multi")
+multi:newAlarm(5):OnRing(function()
+ os.exit(10)
+end)
+multi:mainloop()
diff --git a/multi/integration/loveManager.lua b/multi/integration/loveManager.lua
index 2440ade..5064d8e 100644
--- a/multi/integration/loveManager.lua
+++ b/multi/integration/loveManager.lua
@@ -5,7 +5,9 @@ end
multi.integration={}
multi.integration.love2d={}
multi.integration.love2d.ThreadBase=[[
-__THREADNAME__=({...})[1]
+tab={...}
+__THREADNAME__=tab[2]
+__THREADID__=tab[1]
require("love.filesystem")
require("love.system")
require("love.timer")
@@ -32,8 +34,8 @@ function __sync__()
love.timer.sleep(.001)
if type(data)=="string" then
local cmd,tp,name,d=data:match("(%S-) (%S-) (%S-) (.+)")
- if name=="__DIEPLZ"..__THREADNAME__.."__" then
- error("Thread: "..__THREADNAME__.." has been stopped!")
+ if name=="__DIEPLZ"..__THREADID__.."__" then
+ error("Thread: "..__THREADID__.." has been stopped!")
end
if cmd=="SYNC" then
__proxy__[name]=resolveType(tp,d)
@@ -268,7 +270,7 @@ function multi:newSystemThread(name,func) -- the main method
c.name=name
c.ID=c.name..""
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/multi/integration/shared/shared.lua b/multi/integration/shared/shared.lua
index 92a1b44..e754fc1 100644
--- a/multi/integration/shared/shared.lua
+++ b/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