Package threads

Summary

Classes:
Shared_Variable, Task, Thread, Threads

Procedures:
ClosePool, Dispatch, IsIdle, MakePool, channel, stopWork, worker

Global variables:
Idlers, ToDo, Work, Workforce

Files in package:
thread.icn

Details
Procedures:

ClosePool()

--------------------------------------------------------------------------------
 Shut up shop. Remaining work placed in the queue before the call of ClosePool
 will be executed before closure. Fails if all work has not been done.


Dispatch(p, args)

--------------------------------------------------------------------------------
 Add a task (described by a procedure plus parameters) to the list of tasks
 to be executed by (one of) the pool of worker threads.


IsIdle()

--------------------------------------------------------------------------------
 Fail if there is work in progress, or waiting to be done.


MakePool(n:integer:0)

--------------------------------------------------------------------------------
 Construct a pool of n worker threads.


channel(x, port)


stopWork(reason:string:"")

--------------------------------------------------------------------------------
 dummy procedure used to request thread (self) termination.
 NB. If called directly, causes an "emergency stop"


worker(MyId)

--------------------------------------------------------------------------------
 work thread: repeatedly get a task, which is a list [proc, param1, param2 ....]
              and call the procedure with the supplied parameters.


Global variables:
Idlers -- the first element is a procedure to call and the rest are its parameters. A List of waiting worker threads

ToDo -- A List of tasks to execute. Each task is itself a list where

Work -- A mutex protecting the above

Workforce -- The collection of all worker threads.


This page produced by UniDoc on 2021/04/15 @ 23:59:54.