Home > Class Reference > ENSLIB namespace > %SYSTEM.AbstractWorkMgr
Private  Storage   

%SYSTEM.AbstractWorkMgr


Implement some abstract interfaces for Work Queue Manager subclasses

Inventory


Parameters Properties Methods Queries Indices ForeignKeys Triggers
6 9


Summary


Properties
DeleteTimeout

Methods
Cleanup Clear Help Initialize
Setup TearDown Wait WaitForComplete

Subclasses
%SYSTEM.WorkMgr

Properties


• property DeleteTimeout as %Integer [ InitialExpression = 1 ];
When the work queue oref is killed or goes out of scope this is the timeout we pass to the call the destructor makes to delete the work queue. The delete queue logic will wait for this timeout period for the worker/s to respond but if the worker/s is/are still busy it will force these processes down.

Methods


• method Cleanup(work As %String, args... As %String) as %Status
Normally when a work group is deleted the delete/close is synchronous and so waits for all the worker jobs to finish or be terminated before it returns to the caller. This means the caller can be sure all work has finished and it can cleanup any temporary storage or resources the workers may have been using. This method allows you to specify a callback to be run when the work group is fully deleted which makes the delete/close of the work group asynchronous. So when the work group is deleted it can return immediately to the caller, but the caller can not assume all work has been terminated. Some of the workers may still be finishing their work or may be in the process of being terminated, however once the workers are stopped we will fully delete the work queue and run this 'Cleanup' callback. Note that this callback is not run in a worker that we have called Setup in.
• method Clear(timeout As %Integer = 1) as %Status
Clear any existing work from this work queue, it does this by removing the queue and creating a new one. This will wait for up to timeout seconds for the workers to finish their current task before killing the jobs. When we return from this function all work on the group has terminated so you can cleanup any temporary globals etc used by the workers.
• classmethod Help(method As %String = "") as %String
Write out a list of the methods of this object to the console. Pass the method name as an argument to see the full description for this item.
• classmethod Initialize(qspec As %String = "", ByRef sc As %Status, numworkers As %Integer) as AbstractWorkMgr
Implemented for compatibility with code used to calling 'Initialize' method but new users should call %New to create an instance of this class.
• method Setup(work As %String, args... As %String) as %Status
If you queue a large number of units of work and there is some common setup needed by any process that will run one of these units of work rather than having this setup work done for every work unit you can initalize the worker process once with this method, then it can process any number of work units in this group and when it is done it will run the TearDown. So if you call this method for a work group we will ensure this Setup entry point is called before the worker runs the first unit in this work group. This must be called before you queue any work and the arguments are the same as for the Queue.
• method TearDown(work As %String, args... As %String) as %Status
This is a companion method to Setup to restore a workers process to the previous state if setup work was done. The arguments are the same as for Queue. This must be called before you queue work.
• method Wait(qspec As %String, ByRef atend As %Boolean, timeout As %Integer = -1) as %Status
After work has been queued you can call this to process some work and then return to the caller where the caller will check the atend to see if all the work was processed and if not then you can call this method again to process additional items until atend is true.
The conditions which control when it will return is controlled by timeout argument. If this is -1 (the default) then after each unit of work is signalled as complete and you have a callback queued in QueueCallback which the public variable '%exit' to 1 then this will return to the caller. If timeout is zero we will count completion events until no completions are waiting to be counted and will return to the caller. If timeout is a positive value then this will return to the caller after one work complete event or after the specified number of seconds has elapsed. This method returns atend to show if all the work is complete or if there are still items outstanding. Note that in the function/method called in the QueueCallback callback you can reference the public variable '%workqueue' which is the oref of the instance of the work queue class in order to queue additional work.
• method WaitForComplete(qspec As %String, errorlog As %String) as %Status
After work has been queued this will wait for all the workers to complete. It will display any output the work writes to the current device and it will also combine all the %Status codes that the units of work report and return this combined %Status. If there are no workers then this will execute all the work in this main job during this phase. When this returns all the work queued up to this point has been completed. Also this is the phase that will run the QueueCallback callbacks as the workers jobs report that various units are complete. Note that in the function/method called in the QueueCallback callback you can reference the public variable '%workqueue' which is the oref of the instance of the work queue class in order to queue additional work.