Working on issue with love threaded functions not waiting when in a thread

This commit is contained in:
Ryan Ward 2023-01-18 15:42:38 -05:00
parent 6ed5555706
commit 22f1375380
2 changed files with 28 additions and 32 deletions

View File

@ -22,6 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
]]
traceback = debug.traceback
local multi = {}
local mainloopActive = false
local isRunning = false
@ -1615,6 +1617,7 @@ co_status = {
else
ref.OnError:Fire(ref,ret,r1,r2,r3,r4,r5,r6,r7,r8,r9,r10,r11,r12,r13,r14,r15,r16)
end
print(ref.Name, traceback())
if i then
table.remove(th,i)
else

View File

@ -20,8 +20,7 @@ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
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.
]]
if ISTHREAD then
]] if ISTHREAD then
error("You cannot require the loveManager from within a thread!")
end
local ThreadFileData = [[
@ -62,18 +61,16 @@ function multi:newSystemThread(name,func,...)
c.ID = THREAD_ID
c.thread = love.thread.newThread(ThreadFileData)
c.thread:start(THREAD.dump(func), c.ID, c.name, ...)
c.stab = THREAD.createStaticTable(name)
c.stab = THREAD.createStaticTable(name .. c.ID)
c.OnDeath = multi:newConnection()
c.OnError = multi:newConnection()
GLOBAL["__THREAD_" .. c.ID] = {ID = c.ID, Name = c.name, Thread = c.thread}
GLOBAL["__THREAD_COUNT"] = THREAD_ID
THREAD_ID = THREAD_ID + 1
function c:getName()
return c.name
end
function c:getName() return c.name end
thread:newThread(function()
if name == "TempSystemThread" then
local status_channel = love.thread.getChannel("__"..c.ID.."__MULTI__STATUS_CHANNEL__")
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
local status = status_channel
@ -83,9 +80,7 @@ function multi:newSystemThread(name,func,...)
return not c.thread:isRunning()
end)
else
thread.hold(function()
return not c.thread:isRunning()
end)
thread.hold(function() return not c.thread:isRunning() end)
end
-- If the thread is not running let's handle that.
local thread_err = c.thread:getError()
@ -117,6 +112,4 @@ multi.integration.GLOBAL = GLOBAL
multi.integration.THREAD = THREAD
require("multi.integration.loveManager.extensions")
multi.print("Integrated Love Threading!")
return {init=function()
return GLOBAL,THREAD
end}
return {init = function() return GLOBAL, THREAD end}