OGRE  master
Object-Oriented Graphics Rendering Engine
Ogre::DefaultWorkQueueBase Class Referenceabstract

Base for a general purpose task-based background work queue. More...

#include <OgreWorkQueue.h>

+ Inheritance diagram for Ogre::DefaultWorkQueueBase:

Public Member Functions

 DefaultWorkQueueBase (const String &name=BLANKSTRING)
 Constructor. More...
 
virtual ~DefaultWorkQueueBase ()
 
virtual void _processNextRequest ()
 Process the next request on the queue. More...
 
virtual void _threadMain ()=0
 Main function for each thread spawned. More...
 
void addMainThreadTask (std::function< void()> task) override
 Add a deferred task that will be processed on the main render thread. More...
 
void addTask (std::function< void()> task) override
 Add a new task to the queue. More...
 
const StringgetName () const
 Get the name of the work queue. More...
 
virtual bool getRequestsAccepted () const override
 Returns whether requests are being accepted right now. More...
 
unsigned long getResponseProcessingTimeLimit () const override
 
virtual bool getWorkersCanAccessRenderSystem () const
 Get whether worker threads will be allowed to access render system resources. More...
 
size_t getWorkerThreadCount () const override
 Get the number of worker threads that this queue will start when startup() is called. More...
 
bool isPaused () const override
 Return whether the queue is paused ie not sending more work to workers. More...
 
virtual bool isShuttingDown () const
 Returns whether the queue is trying to shut down. More...
 
void processMainThreadTasks () override
 Process the tasks in the main-thread queue. More...
 
void setPaused (bool pause) override
 Set whether to pause further processing of any requests. More...
 
void setRequestsAccepted (bool accept) override
 Set whether to accept new requests or not. More...
 
void setResponseProcessingTimeLimit (unsigned long ms) override
 
virtual void setWorkersCanAccessRenderSystem (bool access)
 Set whether worker threads will be allowed to access render system resources. More...
 
void setWorkerThreadCount (size_t c) override
 Set the number of worker threads that this queue will start when startup() is called (default 1). More...
 
- Public Member Functions inherited from Ogre::WorkQueue
 WorkQueue ()
 
virtual ~WorkQueue ()
 
uint64 getMainThreadProcessingTimeLimit () const
 Get the time limit imposed on the processing of tasks in a single frame, in milliseconds (0 indicates no limit). More...
 
virtual void processResponses ()
 
void setMainThreadProcessingTimeLimit (uint64 ms)
 Set the time limit imposed on the processing of tasks in a single frame, in milliseconds (0 indicates no limit). More...
 
virtual void shutdown ()=0
 Shut down the queue. More...
 
virtual void startup (bool forceRestart=true)=0
 Start up the queue with the options that have been set. More...
 

Additional Inherited Members

- Public Types inherited from Ogre::WorkQueue
typedef unsigned long long int RequestID
 Numeric identifier for a request. More...
 

Detailed Description

Base for a general purpose task-based background work queue.

Constructor & Destructor Documentation

◆ DefaultWorkQueueBase()

Ogre::DefaultWorkQueueBase::DefaultWorkQueueBase ( const String name = BLANKSTRING)

Constructor.

Call startup() to initialise.

Parameters
nameOptional name, just helps to identify logging output

◆ ~DefaultWorkQueueBase()

virtual Ogre::DefaultWorkQueueBase::~DefaultWorkQueueBase ( )
virtual

Member Function Documentation

◆ getName()

const String& Ogre::DefaultWorkQueueBase::getName ( ) const

Get the name of the work queue.

◆ getWorkersCanAccessRenderSystem()

virtual bool Ogre::DefaultWorkQueueBase::getWorkersCanAccessRenderSystem ( ) const
virtual

Get whether worker threads will be allowed to access render system resources.

Accessing render system resources from a separate thread can require that a context is maintained for that thread. Also, it requires that the render system is running in threadsafe mode, which only happens when OGRE_THREAD_SUPPORT=1. This option defaults to false, which means that threads can not use GPU resources, and the render system can work in non-threadsafe mode, which is more efficient.

◆ setWorkersCanAccessRenderSystem()

virtual void Ogre::DefaultWorkQueueBase::setWorkersCanAccessRenderSystem ( bool  access)
virtual

Set whether worker threads will be allowed to access render system resources.

Accessing render system resources from a separate thread can require that a context is maintained for that thread. Also, it requires that the render system is running in threadsafe mode, which only happens when OGRE_THREAD_SUPPORT=1. This option defaults to false, which means that threads can not use GPU resources, and the render system can work in non-threadsafe mode, which is more efficient. Calling this will have no effect unless the queue is shut down and restarted.

◆ _processNextRequest()

virtual void Ogre::DefaultWorkQueueBase::_processNextRequest ( )
virtual

Process the next request on the queue.

This method is public, but only intended for advanced users to call. The only reason you would call this, is if you were using your own thread to drive the worker processing. The thread calling this method will be the thread used to call the RequestHandler.

◆ _threadMain()

virtual void Ogre::DefaultWorkQueueBase::_threadMain ( )
pure virtual

Main function for each thread spawned.

Implemented in Ogre::DefaultWorkQueue.

◆ isShuttingDown()

virtual bool Ogre::DefaultWorkQueueBase::isShuttingDown ( ) const
inlinevirtual

Returns whether the queue is trying to shut down.

◆ setPaused()

void Ogre::DefaultWorkQueueBase::setPaused ( bool  pause)
overridevirtual

Set whether to pause further processing of any requests.

If true, any further requests will simply be queued and not processed until setPaused(false) is called. Any requests which are in the process of being worked on already will still continue.

Implements Ogre::WorkQueue.

◆ isPaused()

bool Ogre::DefaultWorkQueueBase::isPaused ( ) const
overridevirtual

Return whether the queue is paused ie not sending more work to workers.

Implements Ogre::WorkQueue.

◆ setRequestsAccepted()

void Ogre::DefaultWorkQueueBase::setRequestsAccepted ( bool  accept)
overridevirtual

Set whether to accept new requests or not.

If true, requests are added to the queue as usual. If false, requests are silently ignored until setRequestsAccepted(true) is called.

Implements Ogre::WorkQueue.

◆ getRequestsAccepted()

virtual bool Ogre::DefaultWorkQueueBase::getRequestsAccepted ( ) const
overridevirtual

Returns whether requests are being accepted right now.

Implements Ogre::WorkQueue.

◆ processMainThreadTasks()

void Ogre::DefaultWorkQueueBase::processMainThreadTasks ( )
overridevirtual

Process the tasks in the main-thread queue.

This method must be called from the main render thread to 'pump' tasks through the system. The method will usually try to clear all tasks before returning; however, you can specify a time limit on the tasks processing to limit the impact of spikes in demand by calling setMainThreadProcessingTimeLimit.

Reimplemented from Ogre::WorkQueue.

◆ getResponseProcessingTimeLimit()

unsigned long Ogre::DefaultWorkQueueBase::getResponseProcessingTimeLimit ( ) const
inlineoverridevirtual

◆ setResponseProcessingTimeLimit()

void Ogre::DefaultWorkQueueBase::setResponseProcessingTimeLimit ( unsigned long  ms)
inlineoverridevirtual

◆ getWorkerThreadCount()

size_t Ogre::DefaultWorkQueueBase::getWorkerThreadCount ( ) const
inlineoverridevirtual

Get the number of worker threads that this queue will start when startup() is called.

Reimplemented from Ogre::WorkQueue.

◆ setWorkerThreadCount()

void Ogre::DefaultWorkQueueBase::setWorkerThreadCount ( size_t  c)
inlineoverridevirtual

Set the number of worker threads that this queue will start when startup() is called (default 1).

Calling this will have no effect unless the queue is shut down and restarted.

Reimplemented from Ogre::WorkQueue.

◆ addMainThreadTask()

void Ogre::DefaultWorkQueueBase::addMainThreadTask ( std::function< void()>  task)
overridevirtual

Add a deferred task that will be processed on the main render thread.

Implements Ogre::WorkQueue.

◆ addTask()

void Ogre::DefaultWorkQueueBase::addTask ( std::function< void()>  task)
overridevirtual

Add a new task to the queue.

Implements Ogre::WorkQueue.


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