1. Task API #2
- Posted by Michael Nelson <mikestar13 at sbcglobal.net> Oct 22, 2005
- 491 views
Look great Rob! I am testing a small extension library which will add considerable functionality. New routines are: task_callbacks(i1,i2): this allows a program or library to register callback routines in order to be notified before and after task switching. The callbacks are 0-parameter procedures and use task_self() to identify the current task. This will simplify saving and restoring per task non local data. The task API is disabled in these callbacks, excepting the informational functions task_self(), task_list(), and task_status(). task_lock(): disables task switching until task_unlock() is issued, the current task suspends or kills itself, or the current task's procedure returns. task_terminate(): sets a flag indicating a desire to terminate the program while allowing other tasks to complete. i1=task_terminating(): checks the terminate flag. A task finding this flag set would normally do final cleanup and then return from its procedure. task_create(), task_suspend(), task_kill(), task_clock_stop(), class_clock_start(), and task_yield() are redefined in order to implement the new functionality. I will post this to contributions as soon as testing is completed. Feedback is encouraged. My hope is to develop a standardized library that can be included in task-safe libraries rather than having every library writer roll their own--this will allow multiple task-safe libs to cooperate more effectively as they will be using the same mechanism. -- Mike Nelson