Page 2 of 3
Re: multithreading love with love.thread
Posted: Fri Nov 19, 2010 11:21 pm
by Jasoco
TechnoCat wrote:Jasoco wrote:Maybe if you added a thread stopping code to a love.run() function of your own that would be called when you quit, it would end better instead of crashing. How exactly would you go about stopping any running threads in the middle of their run? Apparently it's not thread:stop().
Try Thread:kill() in love.quit()
Nope. That just caused it to freeze with the colorful spinning wheel. Rather than quitting and crashing.
Re: multithreading love with love.thread
Posted: Sat Nov 20, 2010 12:06 am
by bartbes
Please don't call kill, didn't I put a warning on the wiki?!
Anyway, I don't think this is a bug with threading though, what happens when you use a really basic thread, or when you put the thread code in the main thread?
Re: multithreading love with love.thread
Posted: Sat Nov 20, 2010 12:19 am
by Jasoco
Well, I did notice if I quit right after the first image, but before the second one, it doesn't crash. So maybe it has something to do with calling it more than once?
Re: multithreading love with love.thread
Posted: Wed Dec 08, 2010 5:21 pm
by TechnoCat
I updated the original post to not have dumb loops in it. Also, you can quit the thread with 'q'.
Re: multithreading love with love.thread
Posted: Wed Dec 15, 2010 8:42 am
by saiko-chriskun
what are the advantages of love.thread over lua's built-in coroutines?
Re: multithreading love with love.thread
Posted: Wed Dec 15, 2010 5:22 pm
by TechnoCat
saiko-chriskun wrote:what are the advantages of love.thread over lua's built-in coroutines?
Coroutines are not truly threads. It is my understanding coroutines in Lua will only execute one thread at a time.
http://lua-users.org/wiki/CoroutinesTutorial
Coroutines in Lua are not operating system threads or processes. Coroutines are blocks of Lua code which are created within Lua, and have their own flow of control like threads. Only one coroutine ever runs at a time, and it runs until it activates another coroutine, or yields (returns to the coroutine that invoked it).
Re: multithreading love with love.thread
Posted: Thu Dec 16, 2010 12:44 am
by Mud
saiko-chriskun wrote:what are the advantages of love.thread over lua's built-in coroutines?
Coroutines don't allow concurrent execution. If you resume a coroutine, the coroutine has to yield before control returns to the caller. You can do
cooperative multitasking by cycling through coroutines and resuming them (each coroutine decides how much time it gets, and can potentially never yield controller), whereas threads allow
preemptive multitasking (the task scheduler decides how much time a thread gets).
Re: multithreading love with love.thread
Posted: Thu Jun 23, 2011 1:46 am
by TechnoCat
How would I pass a luasocket connection to a thread? EDIT:
https://bitbucket.org/rude/love/issue/2 ... assing-non
Also, can threads create threads? EDIT: require love.filesystem first.
Re: multithreading love with love.thread
Posted: Thu Jun 23, 2011 4:40 pm
by Taehl
I don't think you can pass connections to threads because, unless I'm mistaken, you can only pass strings and I don't think you can serialize a connection.
Re: multithreading love with love.thread
Posted: Thu Jun 23, 2011 5:09 pm
by slime
You can send and received pretty much anything (including userdata) except tables, AFAIK.