"Threads" for Method Euphoria
- Posted by Michael Nelson <mikestar13 at sbcglobal.net> Aug 17, 2005
- 472 views
I have written a cooperative multitasking manager for Method Euphoria and it will be in the upcoming 2.0 release (along with much else.) It is based on Langwar with addtional features. Task are assigned priorites on a 0 (lowest) to 10 scale, activation times, and repeat intervals. I maintain two priortiy queues, an active queue of task that are ready to run, and a waiting queue of tasks whose activation time has not yet been reached. The active queue is sorted by priority number, the waitng queue by activation time. Each call of next_task polls the waiting queue for tasks which are now ready to run and adds them to the active queue, then it pops the first task from the active queue and runs it. After completion, if the task has a repeat interval, a new activation time is calculated and the task is added back to the waiting queue. I am going to adapt this to a non-OOP lib and contribute it. -- Mike Nelson