Is the Love.update() function assumed to be reentrant? Is it possible for this function to be called from multiple threads?
I ask because in the binary module I'm developing I have a function getting called from every Love.update(). There was a bug that I fixed more or less by accident when I added a reentrancy guard.
I'm running Love 0.7.2 on Ubuntu Natty, if that helps.
Is Love.update reentrant?
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
Re: Is Love.update reentrant?
love.update() is assumed to be global singleton - it updates the state of the program, so every frame you call it just once. This is the design decision to help you as a programmer write better code.MrEricSir wrote:Is the Love.update() function assumed to be reentrant? Is it possible for this function to be called from multiple threads?
Threads, OTOH, are meant as a helper workers for doing cpu-intensive tasks without slowing down the main thread (which means GUI - ie, how fast the program responds to user input). Read more about threads here:
http://love2d.org/wiki/love.thread
You can do it, but it is against a good practice. Following this way is asking for troubles. So in short: don't do that.MrEricSir wrote:I ask because in the binary module I'm developing I have a function getting called from every Love.update(). There was a bug that I fixed more or less by accident when I added a reentrancy guard.
I'm running Love 0.7.2 on Ubuntu Natty, if that helps.
My lovely code lives at GitHub: http://github.com/miko/Love2d-samples
- slime
- Solid Snayke
- Posts: 3144
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Is Love.update reentrant?
love.update is a function that by default gets called once per frame by LÖVE, if it has been defined by you. Every thread is a separate instance of Lua which doesn't contain the main loop by default, so you can't technically call love.update from multiple threads, besides writing a separate loop and love.update function for each thread.
Re: Is Love.update reentrant?
Guess I wasn't very clear with my original question... I'm not asking if I should call Love.update(); I'm not that crazy!
Rather I want to know if there's ever a case where Love itself will call Love.update() from outside the main thread and/or concurrently from the same thread (main or otherwise.)
Rather I want to know if there's ever a case where Love itself will call Love.update() from outside the main thread and/or concurrently from the same thread (main or otherwise.)
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Denver, CO
- Contact:
Re: Is Love.update reentrant?
Maybe this will interest you? love.runMrEricSir wrote:Guess I wasn't very clear with my original question... I'm not asking if I should call Love.update(); I'm not that crazy!
Rather I want to know if there's ever a case where Love itself will call Love.update() from outside the main thread and/or concurrently from the same thread (main or otherwise.)
Re: Is Love.update reentrant?
I believe it's called from the "main thread" (from love.run(), that is). If you want to change the flow, overwrite love.run().MrEricSir wrote:Guess I wasn't very clear with my original question... I'm not asking if I should call Love.update(); I'm not that crazy!
Rather I want to know if there's ever a case where Love itself will call Love.update() from outside the main thread and/or concurrently from the same thread (main or otherwise.)
My game called Hat Cat and the Obvious Crimes Against the Fundamental Laws of Physics is out now!
- bartbes
- Sex machine
- Posts: 4946
- Joined: Fri Aug 29, 2008 10:35 am
- Location: The Netherlands
- Contact:
Re: Is Love.update reentrant?
Since nobody seems to have noticed slime's post, I shall redirect you there, he's right.
Another thread can't call love.update, because it doesn't exist there.
Another thread can't call love.update, because it doesn't exist there.
Re: Is Love.update reentrant?
I realize that another Lua thread can't call love.update, but I imagine Love itself could do such a thing.bartbes wrote:Since nobody seems to have noticed slime's post, I shall redirect you there, he's right.
Another thread can't call love.update, because it doesn't exist there.
At some point I'm going to have to bust out GDB and see if the call to love.update ended up on the callstack twice somehow.
- slime
- Solid Snayke
- Posts: 3144
- Joined: Mon Aug 23, 2010 6:45 am
- Location: Nova Scotia, Canada
- Contact:
Re: Is Love.update reentrant?
The C++ side of LÖVE doesn't know about love.update, it's defined by you in Lua and purely called in Lua by love.run (which you can override if you want).MrEricSir wrote:I realize that another Lua thread can't call love.update, but I imagine Love itself could do such a thing.bartbes wrote:Since nobody seems to have noticed slime's post, I shall redirect you there, he's right.
Another thread can't call love.update, because it doesn't exist there.
At some point I'm going to have to bust out GDB and see if the call to love.update ended up on the callstack twice somehow.
Re: Is Love.update reentrant?
Okay, I'm starting to think this problem has got to be in my own code then.
Another question though: where's the Lua code for love.run on the repo? I wasn't able to find it.
Another question though: where's the Lua code for love.run on the repo? I wasn't able to find it.
Who is online
Users browsing this forum: No registered users and 1 guest