Page 1 of 1

Threading... thing

Posted: Thu Aug 25, 2011 2:06 pm
by kraftman
I've been messing about with threads a lot and I've come up with this.. thing. I'm not sure how useful it is but i thought I'd share it anyway, at the very least it's some sample code for threading.

It basically allows you to create and run the thread from the main love process, dynamically changing what the thread does depending on what you need it for.

To use it you just need to require the file and add "updateThreads()" to love.update

The commands are:

newThread("name") --returns a new thread that is ready to run your code

thread:run (" some code") -- tells the thread to run the code you give it

and functions you can define are:

runGet[key](data)

runPeek[key](data)

these functions will be run whenever the key is present for the given thread.


inside the thread the main and sub threads and called main_thread and sub_thread.

I've include a demo that tells the thread to write a large image with random data and send it back, while progressively updating the percentage bar.

Re: Threading... thing

Posted: Thu Aug 25, 2011 6:54 pm
by TechnoCat
Sounds like a pool of threads.

Re: Threading... thing

Posted: Thu Aug 25, 2011 7:05 pm
by kraftman
how do i mark it as 0.8?

Re: Threading... thing

Posted: Thu Aug 25, 2011 7:22 pm
by Robin
kraftman wrote:how do i mark it as 0.8?
Just say: "Guys, you need LÖVE 0.8.0 to run it." ;)

Re: Threading... thing

Posted: Thu Aug 25, 2011 7:58 pm
by TechnoCat
kraftman wrote:how do i mark it as 0.8?
Oh geez. I should've picked up on that when the error was Thread:set.