Extended Tasking Library 1.0

© November 2005 by Michael A. Nelson

mikestar13@sbcglobal.net

 

WHAT IS THE EXTENDED TASKING LIBRARY?

The Extended Tasking Library extends the multitasking features of Euphoria's new tasking interpreter. It provides a uniform interface for task safe libraries and handles the internal bookkeeping so library writers need not be concerned with details in making their libraries task safe.

The task routines task_clock_start, task_clock_stop, task_create, task_kill, task_schedule, task_suspend, and task_yield are redefined to implement the added functionality. The task routines task_list, task_self, and task_status are not modified.

 

ALPHABETICAL LISTING OF GLOBAL ROUTINES

 

The syntax convention for routines is to show the return value (for functions) and the parameters as type names with digits to distinguish them: object1, integer2, sequence3, etc.

 

task_abort

Variety
procedure
Syntax
task_abort(integer1,atom1)
Description
Initiates a controlled shutdown of the program in which running tasks are given a chance to finish. Integer1 is the exit code to return when the program is terminated, atom1 is a time limit. A new task is created which monitors running tasks: it terminates the program when all other tasks have are suspended or terminated. If this has not occcured when atom1 seconds have elapsed, the program will be terminated. A 0 or negative value for atom1 will not wait, but the termination task will yield once before ending the program to give other tasks a chance to finish. For a genuinely immediate termination, use abort. The task clock is restarted to give real time tasks a chance to finish.
Note
Due to the internal operation of crash_routine, task_abort's controlled shutdown cannot be used in a crash routine.

 

 

task_aborting

Variety
function
Syntax
boolean1=task_aborting()
Description
Returns a boolean indicating whether or not a controlled shutdown initaiated by task_abortis in porgress.
Note
A simple example of usage:
procedure my_task()
	while not task_aborting() do
		-- task body goes here
 	end while
	-- task cleanup goes here
end procedure

 

 

task_callbacks

Variety
procedure
Syntax
task_abort(integer1,integer2)
Description
Sets up callbacks to enable a library or program to save and restore non-private per task data. Integer1 is the routine id of a zero-parameter procedure to be called before each task_yield to save data; integer2 is the routine id or a zero-parmeter procedure to be called after each task_yield to restore data.
Note
The callbacks are for saving and restoring of data only. Most tasking routines are disabled during the execution of the callbacks: only task_aborting, task_list, task_self, and task_status can be called.

 

 

task_lock

Variety
procedure
Syntax
task_lock()
Description
Disables task switching until task_unlock is called.
Note
Suspending or killing the current process or exiting the procedure of the current process implicitly calls task_unlock.

 

 

task_unlock

Variety
procedure
Syntax
task_unlock()
Description
Enables task switching after it has been disabled by task_lock.
Note
No error occurs if task_lock has not been called or if task_unlock is called twice in succession: the call is ignored..