UA Server SDK C++ Bundle  1.4.1.271
 All Classes Namespaces Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
UaThreadPool Class Reference

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...
 

Detailed Description

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.

Constructor & Destructor Documentation

UaThreadPool::UaThreadPool ( OpcUa_UInt32  minThreads,
OpcUa_UInt32  maxThreads 
)

Create a thread pool object with the minimum number of threads passed in.

Parameters
[in]minThreadsthe minimum of threads to use.
[in]maxThreadsthe maximum of threads to use.

Member Function Documentation

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.

Parameters
jobPointer to job base class. Job data is contained in derived class.
Returns
OpcUa_Good if the job was successfully added, bad status if an error occurred in the addJob function

The documentation for this class was generated from the following files: