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?
love.run and async threads
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- slime
- Solid Snayke
- Posts: 3132
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: love.run and async threads
Channels don't use love.event at all. Their operations (push/pop/supply/demand/etc) happen immediately when you call the function.
Re: love.run and async threads
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.
Dang, slime beat me to it.
- parallax7d
- Citizen
- Posts: 82
- Joined: Wed Jul 02, 2014 11:44 pm
Re: love.run and async threads
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.
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.
Re: love.run and async threads
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.
Who is online
Users browsing this forum: No registered users and 89 guests