No reason it has to be named.S0lll0s wrote:I think blocking with :demand() on a named channel should do the trick
Yes, the thread calling demand is asleep.S0lll0s wrote: 2. :demand() is implemented in "smart" C++ (vs. long polling), right?
As you already found out, this is (mostly) what pop does.S0lll0s wrote: 3. Can I somehow build an atomic "tryDemand" method?
Push all the entries, and let each thread just take things from the channel until it's empty?S0lll0s wrote:If I may only supply flat tables (via Thread.run and channels), how do I make threads cooperatively work on a list of entities?
There is none enforced, so that should be pretty high.Azhukar wrote: I believe the limit for number of channels is pretty high.
Why would you not just push all anonymous channels instead, or supply a table of them, instead of their names? Generally speaking you should be using as little named channels as possible (since they're basically globals).S0lll0s wrote:Code: Select all
local meta = love.thread.getChannel("meta") local keys = {} for k,v in pairs( ent ) do love.thread.getChannel(k):push(v) keys[#keys+1] = k end meta:supply( keys ) for _,k in ipairs( keys ) do love.thread.getChannel(k):clear() end
Unfortunately lua tables can't handle this well at all, which is the reason love has a message-passing based API.S0lll0s wrote: Having a way to share actual tables would still be much better.
Memory is shared in threads, always. That said, lua code lives separately, and only love userdata is shared. (Indeed the lua code only ever has a reference, and not the userdata itself.)S0lll0s wrote: And I believe every OS has a method to share RAM between processes (or at least threads)