Davidobot / love.js

LÖVE ported to the web using Emscripten, updated to the latest Emscripten and LÖVE (v11.5)
MIT License
624 stars 28 forks source link

`Channel:demand()` Would freeze entire window when using release version #99

Open ParticleG opened 1 week ago

MrZ626 commented 1 week ago
--------main.lua

-- Wait data with ":getCount()>0"
love.thread.newThread[[
    local channel=love.thread.getChannel("CHN_1")
    print("TH 1: Looping...")
    repeat until channel:getCount()>0
    print("TH 1: Received",channel:pop())
]]:start()

-- Wait data with ":demand()"
love.thread.newThread[[
    local channel=love.thread.getChannel("CHN_2")
    print("TH 2: Demanding...")
    local v=channel:demand()
    print("TH 2: Received",v)
]]:start()

-- Control group, :demand() will timeout after 5s
love.thread.newThread[[
    local channel=love.thread.getChannel("CHN_3")
    print("TH 3: Demanding...")
    local v=channel:demand(2.6)
    print("TH 3: Received",v)
]]:start()

love.timer.sleep(1)

love.thread.getChannel("CHN_1"):push("DATA 1")
love.thread.getChannel("CHN_2"):push("DATA 2")

function love.draw() love.graphics.print("Check console",0,0,0,6) end

image