Working on issue where threads created in threads don't work

This commit is contained in:
2023-01-19 00:16:32 -05:00
parent 22f1375380
commit 0994ee2d2a
3 changed files with 107 additions and 149 deletions
+9 -7
View File
@@ -20,9 +20,12 @@ 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 = [[
ISTHREAD = true
THREAD = require("multi.integration.loveManager.threads")
@@ -35,7 +38,7 @@ math.randomseed(__THREADID__)
math.random()
math.random()
math.random()
stab = THREAD.createStaticTable(__THREADNAME__)
stab = THREAD.createStaticTable(__THREADNAME__ .. __THREADID__)
GLOBAL = THREAD.getGlobal()
multi, thread = require("multi").init()
multi.integration={}
@@ -68,14 +71,13 @@ function multi:newSystemThread(name, func, ...)
GLOBAL["__THREAD_COUNT"] = THREAD_ID
THREAD_ID = THREAD_ID + 1
function c:getName() return c.name end
thread:newThread(function()
thread:newThread(name .. "_System_Thread_Handler",function()
if name == "TempSystemThread" 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
local status = status_channel
if status:peek() ~= nil then
c.statusconnector:Fire(unpack(status:pop()))
if status_channel:peek() ~= nil then
c.statusconnector:Fire(unpack(status_channel:pop()))
end
return not c.thread:isRunning()
end)
@@ -98,7 +100,7 @@ end
function THREAD:newFunction(func, holdme)
return thread:newFunctionBase(function(...)
return multi:newSystemThread("TempSystemThread", func, ...)
return multi:newSystemThread("SystemThreaded Function Handler", func, ...)
end, holdme)()
end
-10
View File
@@ -25,7 +25,6 @@ require("love.timer")
require("love.system")
require("love.data")
require("love.thread")
local socket = require("socket")
local multi, thread = require("multi").init()
local threads = {}
@@ -49,15 +48,6 @@ local function manage(channel, value)
end
end
local function RandomVariable(length)
local res = {}
math.randomseed(socket.gettime()*10000)
for i = 1, length do
res[#res+1] = string.char(math.random(97, 122))
end
return table.concat(res)
end
local GNAME = "__GLOBAL_"
local proxy = {}
function threads.set(name,val)