Page 2 of 2

Re: love.event purpose/use

Posted: Sat Jan 19, 2013 10:25 pm
by Ref
bartbes wrote:In fact, love.event might be nice with threading, too, since it's now thread-safe (except for pump, which you don't need anyway), so you could use an event to tell your main thread your calculation is done (possibly even send the result), and to handle the result.
Does this imply that more than strings and userdata could be returned (just hopeing)?
Anyone have a nice example of a useful event & how it was coded?

Re: love.event purpose/use

Posted: Sun Jan 20, 2013 12:03 am
by bartbes
Inny wrote:I wasn't aware that love.thread preserved SDL_PushEvent's thread-safety.
It doesn't but it doesn't use SDL. (Well, it does, pump moves every sdl event over to love's events, which is why that's the only non thread-safe function.)
Ref wrote:Does this imply that more than strings and userdata could be returned (just hopeing)?
It has the same restrictions as threads have, that is, only primitive types, light userdata and love userdata.
I am not sure why you'd expect otherwise, it uses the same variant type internally, which is limited by these things simply because lua is. That is, we can't move non-love full userdata, since we don't know what it is, and tables are extremely hard to serialize and deserialize properly. (I wouldn't be surprised if someone told me it has been proven it's impossible to serialize all possible tables.)