love.event purpose/use

Questions about the LÖVE API, installing LÖVE and other support related questions go here.
Forum rules
Before you make a thread asking for help, read this.
User avatar
Ref
Party member
Posts: 702
Joined: Wed May 02, 2012 11:05 pm

Re: love.event purpose/use

Post 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?
User avatar
bartbes
Sex machine
Posts: 4946
Joined: Fri Aug 29, 2008 10:35 am
Location: The Netherlands
Contact:

Re: love.event purpose/use

Post 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.)
Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 3 guests