love.run and async threads

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.
Post Reply
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

love.run and async threads

Post by parallax7d »

Are messages over channels totally asynchronous, or are they pumped as part of event?

Are threads interacting with imagedata/other love types totally asynch? For example, the mutex operations occur regardless of what point in love.run the main thread is in?
User avatar
slime
Solid Snayke
Posts: 3132
Joined: Mon Aug 23, 2010 6:45 am
Location: Nova Scotia, Canada
Contact:

Re: love.run and async threads

Post by slime »

Channels don't use love.event at all. Their operations (push/pop/supply/demand/etc) happen immediately when you call the function.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: love.run and async threads

Post by raidho36 »

That is exactly right. Channels are completely separate from events pool, you even poll them separately. And a mutex locks whenever it's called to do that, instantly - the other thread may be halfway through executing a math operation. Plus, love.run is not a special function, it's just default main loop in case you don't wish to use your own.

Dang, slime beat me to it.
User avatar
parallax7d
Citizen
Posts: 82
Joined: Wed Jul 02, 2014 11:44 pm

Re: love.run and async threads

Post by parallax7d »

you guys are quick today!

Just so I get this right, in theory worker threads can access and edit imagedata, and also send messages to main over channels, and the channel method will preempt whatever main is doing, totally and 100% irregardless of what part of the game loop main is currently executing?

*edit: just to note, I understand the cpu scheduler decides when to do these things, so no assumptions can be made about when one thread or the other thread does something. I'm not worried about that, just how threads interrupt the game loop.
User avatar
raidho36
Party member
Posts: 2063
Joined: Mon Jun 17, 2013 12:00 pm

Re: love.run and async threads

Post by raidho36 »

Threads don't interrupt main game loop nor each other, as long as you're not simultaneously trying to access same exact resource that's locked behind mutex.
Post Reply

Who is online

Users browsing this forum: Bing [Bot], Google [Bot] and 160 guests