UA Server SDK C++ Bundle
1.4.1.271
|
This class is used to manager a pool of threads. More...
#include <uathreadpool.h>
Public Member Functions | |
UaThreadPool (OpcUa_UInt32 minThreads, OpcUa_UInt32 maxThreads) | |
Create a thread pool object with the minimum number of threads passed in. More... | |
virtual | ~UaThreadPool () |
Destroys the thread pool object. | |
OpcUa_StatusCode | addJob (UaThreadPoolJob *job) |
Adds a job to be executed by the thread pool. More... | |
This class is used to manager a pool of threads.
This class manages and recycles individual UaThread objects to help reduce thread creation costs in programs that use threads. It also ensures that a maximum number of threads is used to execute worker thread jobs. Jobs are passed in as UaThreadPoolJob.
During the creation of the thread pool a minimum and maximum number of threads is defined. The thread pool creates the minimum number of threads when it is created. It creates more threads if needed but not more than defined as maximum.
See UaThreadPoolJob for an example.
It is not possible to create plane copies of this Class. It is not possible to use the default constructor.
UaThreadPool::UaThreadPool | ( | OpcUa_UInt32 | minThreads, |
OpcUa_UInt32 | maxThreads | ||
) |
Create a thread pool object with the minimum number of threads passed in.
[in] | minThreads | the minimum of threads to use. |
[in] | maxThreads | the maximum of threads to use. |
OpcUa_StatusCode UaThreadPool::addJob | ( | UaThreadPoolJob * | job | ) |
Adds a job to be executed by the thread pool.
The thread pool executes the job in a worker thread and deletes the job after the execution. If all worker threads are active, this method blocks until a worker thread is available.
job | Pointer to job base class. Job data is contained in derived class. |