distantcam, on 15 October 2013 - 01:52 AM, said:
Yeah, I usually forget to update it. I should really just have it download the install program from the repo and run that, but for now I'll just edit in the newest installer into it. Today, I think I'll be cleaning up OP and working on making see.concurrent a bit more full fledged (tasks, future objects, thread joining, etc.).
Edit: Updated OP with relevant new feature set and my teamspeak. Later I'll add example code to the OP to show off the features a bit better.
Edit: Aaand this is awesome.
In addition to tasks, I also added a convenience function for running process-heavy code. When Thread.work is first called, it saves the time it was run inside the thread. Once it gets called 1/20 seconds after it was first called, it sleeps and resets the time. As a rule of thumb, you should use this function whenever your thread needs to do busy calculations.
[email protected] see.concurrent.Thread [email protected] see.concurrent.Task function Test.main() local piTask = Task.new(calculatePi, 1000000):setCallback(function(result) System.print(result) end) repeat System.print("Waiting...") Thread.sleep(1) until piTask:isFinished() end function calculatePi(iter) local pi = 4 for i = 1, iter * 2, 2 do Thread.work() pi = pi - (4/(1 + i * 2)) pi = pi + (4/(3 + i * 2)) end return pi end













