mirror of
https://github.com/rayaman/multi.git
synced 2026-09-05 07:27:35 -04:00
Threading working in love2d
This commit is contained in:
@@ -22,7 +22,7 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
||||
SOFTWARE.
|
||||
]]
|
||||
local multi, thread = require("multi"):init()
|
||||
local GLOBAL, THREAD = multi.integration.GLOBAL,multi.integration.THREAD
|
||||
local GLOBAL, THREAD = multi.integration.GLOBAL, multi.integration.THREAD
|
||||
|
||||
local function stripUpValues(func)
|
||||
local dmp = string.dump(func)
|
||||
@@ -156,7 +156,7 @@ function multi:newSystemThreadedJobQueue(n)
|
||||
end
|
||||
end)
|
||||
for i=1,c.cores do
|
||||
multi:newSystemThread("JobQueue_"..jqc.."_worker_"..i,function(jqc)
|
||||
multi:newSystemThread("STJQ_"..multi.randomString(8),function(jqc)
|
||||
local GLOBAL, THREAD = require("multi.integration.pseudoManager"):init()
|
||||
local multi, thread = require("multi"):init()
|
||||
local clock = os.clock
|
||||
@@ -217,4 +217,5 @@ function multi:newSystemThreadedConnection(name)
|
||||
GLOBAL[name or "_"] = conn
|
||||
return conn
|
||||
end
|
||||
|
||||
require("multi.integration.sharedExtensions")
|
||||
@@ -24,6 +24,8 @@ SOFTWARE.
|
||||
package.path = "?/init.lua;?.lua;" .. package.path
|
||||
local multi, thread = require("multi"):init()
|
||||
|
||||
local pseudoProcessor = multi:newProcessor()
|
||||
|
||||
if multi.integration then
|
||||
return {
|
||||
init = function()
|
||||
@@ -89,7 +91,7 @@ function multi:newSystemThread(name, func, ...)
|
||||
|
||||
local GLOBAL, THREAD = activator.init(thread, env)
|
||||
|
||||
local th = thread:newISOThread(name, func, env, ...)
|
||||
local th = pseudoProcessor:newISOThread(name, func, env, ...)
|
||||
th.Type = multi.registerType("s_thread", "pseudoThreads")
|
||||
th.OnError(multi.error)
|
||||
|
||||
|
||||
@@ -110,6 +110,10 @@ local function INIT(thread)
|
||||
end
|
||||
end
|
||||
|
||||
function THREAD.sync()
|
||||
thread.sleep(.5)
|
||||
end
|
||||
|
||||
return GLOBAL, THREAD
|
||||
end
|
||||
|
||||
|
||||
Reference in New Issue
Block a user