Working on 16.0.0 #53
@ -153,6 +153,29 @@ Removed
|
||||
|
||||
Fixed
|
||||
---
|
||||
- Oversight with how pushStatus worked with nesting threaded functions, connections and forwarding events
|
||||
```lua
|
||||
func = thread:newFunction(function()
|
||||
for i=1,10 do
|
||||
thread.sleep(1)
|
||||
thread.pushStatus(i)
|
||||
end
|
||||
end)
|
||||
|
||||
func2 = thread:newFunction(function()
|
||||
local ref = func()
|
||||
ref.OnStatus(function(num)
|
||||
-- do stuff with this data
|
||||
|
||||
thread.pushStatus(num*2) -- Technically this is not ran within a thread. This is ran outside of a thread inside the thread handler.
|
||||
end)
|
||||
end)
|
||||
|
||||
local handler = func2()
|
||||
handler.OnStatus(function(num)
|
||||
print(num)
|
||||
end)
|
||||
```
|
||||
|
||||
ToDo
|
||||
---
|
||||
|
||||
18
init.lua
18
init.lua
@ -30,6 +30,7 @@ local thread = {}
|
||||
local processes = {}
|
||||
local find_optimization = false
|
||||
local threadManager
|
||||
local __CurrentConnectionThread
|
||||
|
||||
if not _G["$multi"] then
|
||||
_G["$multi"] = {multi = multi, thread = thread}
|
||||
@ -314,6 +315,17 @@ function multi:newConnection(protect, func, kill)
|
||||
function c:fastMode() return self end
|
||||
|
||||
function c:Connect(func)
|
||||
local th
|
||||
if thread.getRunningThread then
|
||||
th = thread.getRunningThread()
|
||||
end
|
||||
if th then
|
||||
local fref = func
|
||||
func = function(...)
|
||||
__CurrentConnectionThread = th
|
||||
fref(...)
|
||||
end
|
||||
end
|
||||
table.insert(call_funcs, func)
|
||||
local temp = {fast = true}
|
||||
setmetatable(temp,{
|
||||
@ -1244,7 +1256,7 @@ local function cleanReturns(...)
|
||||
end
|
||||
|
||||
function thread.pushStatus(...)
|
||||
local t = thread.getRunningThread()
|
||||
local t = thread.getRunningThread() or __CurrentConnectionThread
|
||||
t.statusconnector:Fire(...)
|
||||
end
|
||||
|
||||
@ -1286,8 +1298,8 @@ function thread:newFunctionBase(generator, holdme)
|
||||
return cleanReturns(rets[1],rets[2],rets[3],rets[4],rets[5],rets[6],rets[7],rets[8],rets[9],rets[10],rets[11],rets[12],rets[13],rets[14],rets[15],rets[16])
|
||||
end
|
||||
end
|
||||
tfunc.__call = function(t,...)
|
||||
if t.Active == false then
|
||||
tfunc.__call = function(th,...)
|
||||
if th.Active == false then
|
||||
if holdme then
|
||||
return nil, "Function is paused"
|
||||
end
|
||||
|
||||
@ -47,7 +47,14 @@ multi.integration.THREAD = THREAD
|
||||
pcall(require,"multi.integration.loveManager.extensions")
|
||||
stab["returns"] = {THREAD.loadDump(__FUNC__)(unpack(__IMPORTS))}
|
||||
]]
|
||||
|
||||
local multi, thread = require("multi"):init()
|
||||
|
||||
-- We do not want to load this module twice
|
||||
if multi.integration and multi.integration.THREAD then
|
||||
return multi.integration.GLOBAL, multi.integration.THREAD
|
||||
end
|
||||
|
||||
local THREAD = {}
|
||||
__THREADID__ = 0
|
||||
__THREADNAME__ = "MainThread"
|
||||
@ -55,8 +62,6 @@ multi.integration = {}
|
||||
local THREAD = require("multi.integration.loveManager.threads")
|
||||
local GLOBAL = THREAD.getGlobal()
|
||||
local THREAD_ID = 1
|
||||
local OBJECT_ID = 0
|
||||
local stf = 0
|
||||
|
||||
function multi:newSystemThread(name, func, ...)
|
||||
local c = {}
|
||||
@ -72,7 +77,7 @@ function multi:newSystemThread(name, func, ...)
|
||||
THREAD_ID = THREAD_ID + 1
|
||||
function c:getName() return c.name end
|
||||
thread:newThread(name .. "_System_Thread_Handler",function()
|
||||
if name == "TempSystemThread" then
|
||||
if name == "SystemThreaded Function Handler" then
|
||||
local status_channel = love.thread.getChannel("STATCHAN_" .. c.ID)
|
||||
thread.hold(function()
|
||||
-- While the thread is running we might as well do something in the loop
|
||||
|
||||
@ -97,9 +97,9 @@ function threads.kill()
|
||||
end
|
||||
|
||||
function threads.pushStatus(...)
|
||||
local status_channel = love.thread.getChannel("__"..__THREADID__.."__MULTI__STATUS_CHANNEL__")
|
||||
local status_channel = love.thread.getChannel("STATCHAN_" ..__THREADID__)
|
||||
local args = {...}
|
||||
status_channel:push(__THREADID__, args)
|
||||
status_channel:push(args)
|
||||
end
|
||||
|
||||
function threads.getThreads()
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user