First off, totally enjoying Love and Lua, picked it up about 2 weeks ago and been busy trying soo many things.
So this is probably just a Lua question mainly unless something like love.graphics does some kinda threading I don't know about yet. When my process runs, is it single threaded? I keep finding myself trying to code defensively against ConcurrentAccessException type stuff (yes java guy by trade), and it occurs to me that I don't think I have to. Is this true? When a callback happens and its accessing a global var, that method is the only thing executing at that time yes?
Thanks!
Lua/Love order of exection with callbacks
-
- Prole
- Posts: 4
- Joined: Mon May 27, 2013 10:20 pm
Re: Lua/Love order of exection with callbacks
By default you only have one thread that executes the Lua code. The LÖVE code you call with Lua functions also runs in that thread. No need to worry about multithreading issues. Take a look at love.run to see the main loop.
You only have to think about concurrent access if you start another thread with the love.thread module. The Lua state for the new thread is completely separate and you can safely pass messages with the Thread API, but other parts are not safe and may cause issues. For example, the ImageData object got some mutex locks, but SoundData doesn't have it (yet?).
The love.audio module also starts a thread, but this is not visible to the lover as it's only to manage decoding and buffer queues.
You only have to think about concurrent access if you start another thread with the love.thread module. The Lua state for the new thread is completely separate and you can safely pass messages with the Thread API, but other parts are not safe and may cause issues. For example, the ImageData object got some mutex locks, but SoundData doesn't have it (yet?).
The love.audio module also starts a thread, but this is not visible to the lover as it's only to manage decoding and buffer queues.
Shallow indentations.
-
- Prole
- Posts: 4
- Joined: Mon May 27, 2013 10:20 pm
Re: Lua/Love order of exection with callbacks
That's exactly what I was hoping to hear. Ty for the link to love.run, makes much more sense now.
Who is online
Users browsing this forum: Bing [Bot] and 3 guests