OpenTAP 9.25
API Reference
Public Types | Public Member Functions | Public Attributes | Properties | List of all members
OpenTap.WorkQueue Class Reference

Work Queue used for result processing in sequence but asynchronously. It uses the ThreadManager to automatically clean up threads that have been idle for a while. When the WorkQueue is disposed, the used thread is immediately returned to the ThreadManager. More...

Inherits IDisposable.

Public Types

enum  Options { None = 0 , LongRunning = 1 , TimeAveraging = 2 }
 Options for WorkQueues. More...
 

Public Member Functions

 WorkQueue (Options options, string name="")
 Creates a new instance of WorkQueue. More...
 
 WorkQueue (Options options, string name="", TapThread threadContext=null)
 Creates a new instance of WorkQueue. More...
 
void EnqueueWork (Action a)
 Enqueue a new piece of work to be handled in the future.
 
void Dispose ()
 Give the thread back to the thread manager.
 
void Wait ()
 Waits for the workqueue to become empty.
 

Public Attributes

int Timeout = 5
 The amount of idle time to wait before giving the thread back to the threading manager. This has no effect if the LongRunning option is selected.
 
readonly string Name
 A name of identifying the work queue.
 

Properties

TimeSpan AverageTimeSpent [get]
 The average time spent for each task. Only available if Options.TImeAveraging is enabled.
 
int QueueSize [get]
 The current number of items in the work queue. If called from the worker thread, this number will be 0 for that last worker.
 

Detailed Description

Work Queue used for result processing in sequence but asynchronously. It uses the ThreadManager to automatically clean up threads that have been idle for a while. When the WorkQueue is disposed, the used thread is immediately returned to the ThreadManager.

Member Enumeration Documentation

◆ Options

Options for WorkQueues.

Enumerator
None 

No options.

LongRunning 

The thread is not returned to the ThreadManager when it has been idle for some time. In this situation the WorkQueue must be disposed manually.

TimeAveraging 

Time averaging is enabled. Each piece of work will have measured time spent.

Constructor & Destructor Documentation

◆ WorkQueue() [1/2]

OpenTap.WorkQueue.WorkQueue ( Options  options,
string  name = "" 
)
inline

Creates a new instance of WorkQueue.

Parameters
optionsOptions.
nameA name to identify a work queue.

◆ WorkQueue() [2/2]

OpenTap.WorkQueue.WorkQueue ( Options  options,
string  name = "",
TapThread  threadContext = null 
)
inline

Creates a new instance of WorkQueue.

Parameters
optionsOptions.
nameA name to identify a work queue.
threadContextThe thread context in which to run work jobs. The default value causes the context to be the parent of an enqueuing thread.

OpenTAP 9.25 API built Tue Aug 6 2024 07:49:25