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.
Threading... thing
Threading... thing
- Attachments
-
- autothread.lua
- (1.36 KiB) Downloaded 87 times
-
- AutoThread.love
- (1.16 KiB) Downloaded 115 times
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Threading... thing
Sounds like a pool of threads.
Re: Threading... thing
how do i mark it as 0.8?
- Robin
- The Omniscient
- Posts: 6506
- Joined: Fri Feb 20, 2009 4:29 pm
- Location: The Netherlands
- Contact:
Re: Threading... thing
Just say: "Guys, you need LÖVE 0.8.0 to run it."kraftman wrote:how do i mark it as 0.8?
Help us help you: attach a .love.
- TechnoCat
- Inner party member
- Posts: 1611
- Joined: Thu Jul 30, 2009 12:31 am
- Location: Milwaukee, WI
- Contact:
Re: Threading... thing
Oh geez. I should've picked up on that when the error was Thread:set.kraftman wrote:how do i mark it as 0.8?
Who is online
Users browsing this forum: Bing [Bot] and 4 guests