Threading working in love2d

This commit is contained in:
2024-02-24 23:05:05 -05:00
parent 42b4e0fcf4
commit e3ac0951ab
18 changed files with 210 additions and 999 deletions
+3 -2
View File
@@ -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")
+3 -1
View File
@@ -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)
+4
View File
@@ -110,6 +110,10 @@ local function INIT(thread)
end
end
function THREAD.sync()
thread.sleep(.5)
end
return GLOBAL, THREAD
end