Go to the documentation of this file.
28 #ifndef __OgreWorkQueue_H__
29 #define __OgreWorkQueue_H__
228 virtual void startup(
bool forceRestart =
true) = 0;
273 bool forceSynchronous =
false,
bool idleThread =
false) = 0;
435 bool forceSynchronous =
false,
bool idleThread =
false);
498 : mHandler(handler) {}
OGRE_MUTEX(mChannelMapMutex)
map< uint16, ResponseHandlerList >::type ResponseHandlerListByChannel
uint16 mChannel
The request channel, as an integer.
ResponseHandlerListByChannel mResponseHandlers
virtual bool isPaused() const =0
Return whether the queue is paused ie not sending more work to workers.
#define OGRE_LOCK_RW_MUTEX_READ(name)
uint16 getType() const
Get the type of this request within the given channel.
unsigned long mResposeTimeLimitMS
virtual bool isShuttingDown() const
Returns whether the queue is trying to shut down.
virtual bool getRequestsAccepted() const
Returns whether requests are being accepted right now.
virtual void setResponseProcessingTimeLimit(unsigned long ms)=0
Set the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
bool mSuccess
Whether the work item succeeded or not.
Interface to a general purpose request / response style background work queue.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
General purpose request structure.
const String & getMessages() const
Get any diagnostic messages about the process.
virtual void handleResponse(const Response *res, const WorkQueue *srcQ)=0
The handler method every subclass must implement.
virtual void abortRequestsByChannel(uint16 channel)
Abort all previously issued requests in a given channel.
virtual void _threadMain()=0
Main function for each thread spawned.
RequestHandler * getHandler()
Get handler pointer - note, only use this for == comparison or similar, do not attempt to call it as ...
virtual uint16 getChannel(const String &channelName)
Get a channel ID for a given channel name.
virtual void abortAllRequests()=0
Abort all previously issued requests.
const Request * getRequest() const
Get the request that this is a response to (NB destruction destroys this)
bool mWorkerRenderSystemAccess
virtual void setWorkerThreadCount(size_t c)
Set the number of worker threads that this queue will start when startup() is called (default 1).
String mMessages
Any diagnostic messages.
OGRE_RW_MUTEX(mRequestHandlerMutex)
virtual void abortRequest(RequestID id)=0
Abort a previously issued request.
const Request * mRequest
Pointer to the request that this response is in relation to.
RequestHandlerHolder(RequestHandler *handler)
const String & getName() const
Get the name of the work queue.
OGRE_MUTEX(mRequestMutex)
RequestID getID() const
Get the identifier of this request.
Response(const Request *rq, bool success, const Any &data, const String &msg=StringUtil::BLANK)
virtual void _processNextRequest()
Process the next request on the queue.
virtual void abortRequest(RequestID id)
Abort a previously issued request.
virtual void abortPendingRequestsByChannel(uint16 channel)
Abort all previously issued requests in a given channel.
virtual void removeResponseHandler(uint16 channel, ResponseHandler *rh)
Remove a Response handler.
Variant type that can hold Any other type.
virtual RequestID addRequest(uint16 channel, uint16 requestType, const Any &rData, uint8 retryCount=0, bool forceSynchronous=false, bool idleThread=false)=0
Add a new request to the queue.
virtual void setWorkersCanAccessRenderSystem(bool access)
Set whether worker threads will be allowed to access render system resources.
General purpose response structure.
virtual unsigned long getResponseProcessingTimeLimit() const =0
Get the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
virtual void abortAllRequests()
Abort all previously issued requests.
unsigned long long int RequestID
Numeric identifier for a request.
void abortRequest() const
Set the abort flag.
RequestHandlerListByChannel mRequestHandlers
RequestID mID
Identifier (assigned by the system)
Intermediate structure to hold a pointer to a request handler which provides insurance against the ha...
map< String, uint16 >::type ChannelMap
virtual void startup(bool forceRestart=true)=0
Start up the queue with the options that have been set.
virtual ~RequestHandler()
RequestQueue mProcessQueue
#define OGRE_LOCK_RW_MUTEX_WRITE(name)
void abortRequest()
Abort the request.
void processRequestResponse(Request *r, bool synchronous)
virtual bool canHandleResponse(const Response *res, const WorkQueue *srcQ)
Return whether this handler can process a given response.
OGRE_MUTEX(mProcessMutex)
virtual void setRequestsAccepted(bool accept)=0
Set whether to accept new requests or not.
Request(uint16 channel, uint16 rtype, const Any &rData, uint8 retry, RequestID rid)
Constructor.
uint16 getChannel() const
Get the request channel (top level categorisation)
virtual void addResponseHandler(uint16 channel, ResponseHandler *rh)=0
Add a response handler instance to the queue.
virtual ~DefaultWorkQueueBase()
DefaultWorkQueueBase(const String &name=StringUtil::BLANK)
Constructor.
virtual size_t getWorkerThreadCount() const
Get the number of worker threads that this queue will start when startup() is called.
RequestQueue mIdleRequestQueue
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Any mData
Data associated with the result of the process.
SharedPtr< RequestHandlerHolder > RequestHandlerHolderPtr
bool succeeded() const
Return whether this is a successful response.
size_t mWorkerThreadCount
virtual void abortPendingRequestsByChannel(uint16 channel)=0
Abort all previously issued requests in a given channel.
Interface definition for a handler of responses.
virtual void setPaused(bool pause)=0
Set whether to pause further processing of any requests.
virtual void processResponses()
Process the responses in the queue.
Response * processRequest(Request *r)
virtual Response * handleRequest(const Request *req, const WorkQueue *srcQ)=0
The handler method every subclass must implement.
list< ResponseHandler * >::type ResponseHandlerList
virtual bool isPaused() const
Return whether the queue is paused ie not sending more work to workers.
virtual void processResponses()=0
Process the responses in the queue.
virtual void setResponseProcessingTimeLimit(unsigned long ms)
Set the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
ResponseQueue mResponseQueue
virtual void removeRequestHandler(uint16 channel, RequestHandler *rh)
Remove a request handler.
uint8 getRetryCount() const
Get the remaining retry count.
virtual bool getRequestsAccepted() const =0
Returns whether requests are being accepted right now.
virtual void addResponseHandler(uint16 channel, ResponseHandler *rh)
Add a response handler instance to the queue.
void addRequestWithRID(RequestID rid, uint16 channel, uint16 requestType, const Any &rData, uint8 retryCount)
Put a Request on the queue with a specific RequestID.
virtual void shutdown()=0
Shut down the queue.
const Any & getData() const
Get the user details of this request.
RequestQueue mRequestQueue
Reference-counted shared pointer, used for objects where implicit destruction is required.
virtual bool getWorkersCanAccessRenderSystem() const
Get whether worker threads will be allowed to access render system resources.
const Any & getData() const
Return the response data (user defined, only valid on success)
virtual ~ResponseHandler()
uint8 mRetryCount
Retry count - set this to non-zero to have the request try again on failure.
uint16 mType
The request type, as an integer within the channel (user can define enumerations on this)
virtual void abortRequestsByChannel(uint16 channel)=0
Abort all previously issued requests in a given channel.
Any mData
The details of the request (user defined)
list< RequestHandlerHolderPtr >::type RequestHandlerList
virtual void removeResponseHandler(uint16 channel, ResponseHandler *rh)=0
Remove a Response handler.
Response * handleRequest(const Request *req, const WorkQueue *srcQ)
Process a request if possible.
WorkerFunc(DefaultWorkQueueBase *q)
bool processIdleRequests()
Base for a general purpose request / response style background work queue.
map< uint16, RequestHandlerList >::type RequestHandlerListByChannel
deque< Response * >::type ResponseQueue
Interface definition for a handler of requests.
RequestHandler * mHandler
bool getAborted() const
Get the abort flag.
virtual unsigned long getResponseProcessingTimeLimit() const
Get the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
virtual void removeRequestHandler(uint16 channel, RequestHandler *rh)=0
Remove a request handler.
virtual void setPaused(bool pause)
Set whether to pause further processing of any requests.
DefaultWorkQueueBase * mQueue
virtual void addRequestHandler(uint16 channel, RequestHandler *rh)
Add a request handler instance to the queue.
virtual void setRequestsAccepted(bool accept)
Set whether to accept new requests or not.
virtual void notifyWorkers()=0
Notify workers about a new request.
virtual bool canHandleRequest(const Request *req, const WorkQueue *srcQ)
Return whether this handler can process a given request.
void processResponse(Response *r)
OGRE_MUTEX(mResponseMutex)
deque< Request * >::type RequestQueue
virtual RequestID addRequest(uint16 channel, uint16 requestType, const Any &rData, uint8 retryCount=0, bool forceSynchronous=false, bool idleThread=false)
Add a new request to the queue.
virtual void addRequestHandler(uint16 channel, RequestHandler *rh)=0
Add a request handler instance to the queue.
Copyright © 2012 Torus Knot Software Ltd

This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.