DWFCore::DWFThreadPool Class Reference

#include "dwfcore/ThreadPool.h"

Inheritance diagram for DWFCore::DWFThreadPool:

Inheritance graph
[legend]
Collaboration diagram for DWFCore::DWFThreadPool:

Collaboration graph
[legend]
List of all members.

Detailed Description

This class manages worker threads and executes DWFThreadWorker objects within them.

Since:
1.0.1
The thread pool has two basic parts: a producer-consumer queue of worker threads and an internal queue monitor. The queue contains DWFThread objects that operate in a well-defined algorithm and allow the execution of DWFThreadWorker objects within. When the thread pool is asked to run a thread worker, it will block the requesting thread a pooled thread becomes available (i.e. returned to the queue.) The monitor is itself a thread worker that mediates requests among the control interfaces, the pool and the worker threads. The monitor is never exposed publicly.

Todo:
Internal requests are made to the monitor in a non-blocking fashion and timeout after 1 second. Review this logic and/or make these timeouts adjustable.
Examples:

Threads/Threads.cpp.

Definition at line 157 of file ThreadPool.h.

Public Member Functions

_DWFCORE_API DWFThreadPool () throw ()
_DWFCORE_API ~DWFThreadPool () throw ()
_DWFCORE_API void init (unsigned int nThreads) throw ( DWFException )
_DWFCORE_API DWFThreadPool::Controllerrun (DWFThreadWorker &rWorker) throw ( DWFException )

Friends

class DWFThread

Classes

class  Controller
 This interface returned by thread pool for controlling a running pooled worker thread. More...


Constructor & Destructor Documentation

_DWFCORE_API DWFCore::DWFThreadPool::DWFThreadPool  )  throw ()
 

Constructor

Exceptions:
None 

_DWFCORE_API DWFCore::DWFThreadPool::~DWFThreadPool  )  throw ()
 

Destructor

Exceptions:
None 


Member Function Documentation

_DWFCORE_API void DWFCore::DWFThreadPool::init unsigned int  nThreads  )  throw ( DWFException )
 

Initializes the pool by creating and starting the worker threads and the monitor.

Parameters:
nThreads The number of threads that will be available in the pool. This number must be greater than zero.
Exceptions:
DWFException 
Examples:
Threads/Threads.cpp.

_DWFCORE_API DWFThreadPool::Controller* DWFCore::DWFThreadPool::run DWFThreadWorker rWorker  )  throw ( DWFException )
 

Runs the worker in a pooled thread. This call will block until a pooled thread is available.

Parameters:
rWorker The worker to run in a pooled thread.
Returns:
A pointer to a thread control interface. The caller is reponsible for releasing this pointer with the DWFCORE_FREE_OBJECT macro.
Examples:
Threads/Threads.cpp.


The documentation for this class was generated from the following file:
Generated on Tue Jan 6 22:39:42 2009 for Autodesk DWF Core Library by  doxygen 1.4.5