OpenMW
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
Public Member Functions | Private Attributes | List of all members
SceneUtil::WorkQueue Class Reference

A work queue that users can push work items onto, to be completed by one or more background threads. More...

#include <workqueue.hpp>

Inheritance diagram for SceneUtil::WorkQueue:
Collaboration diagram for SceneUtil::WorkQueue:

Public Member Functions

 WorkQueue (int numWorkerThreads=1)
 
 ~WorkQueue ()
 
void addWorkItem (osg::ref_ptr< WorkItem > item, bool front=false)
 
osg::ref_ptr< WorkItemremoveWorkItem ()
 

Private Attributes

bool mIsReleased
 
std::deque< osg::ref_ptr
< WorkItem > > 
mQueue
 
OpenThreads::Mutex mMutex
 
OpenThreads::Condition mCondition
 
std::vector< WorkThread * > mThreads
 

Detailed Description

A work queue that users can push work items onto, to be completed by one or more background threads.

Note
Work items will be processed in the order that they were given in, however if multiple work threads are involved then it is possible for a later item to complete before earlier items.

Constructor & Destructor Documentation

SceneUtil::WorkQueue::WorkQueue ( int  numWorkerThreads = 1)
SceneUtil::WorkQueue::~WorkQueue ( )

Member Function Documentation

void SceneUtil::WorkQueue::addWorkItem ( osg::ref_ptr< WorkItem item,
bool  front = false 
)

Add a new work item to the back of the queue.

The work item's waitTillDone() method may be used by the caller to wait until the work is complete.
Parameters
frontIf true, add item to the front of the queue. If false (default), add to the back.

Here is the caller graph for this function:

osg::ref_ptr< WorkItem > SceneUtil::WorkQueue::removeWorkItem ( )

Get the next work item from the front of the queue. If the queue is empty, waits until a new item is added. If the workqueue is in the process of being destroyed, may return NULL.

Used internally by the WorkThread.

Here is the caller graph for this function:

Member Data Documentation

OpenThreads::Condition SceneUtil::WorkQueue::mCondition
private
bool SceneUtil::WorkQueue::mIsReleased
private
OpenThreads::Mutex SceneUtil::WorkQueue::mMutex
private
std::deque<osg::ref_ptr<WorkItem> > SceneUtil::WorkQueue::mQueue
private
std::vector<WorkThread*> SceneUtil::WorkQueue::mThreads
private

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