Go to the documentation of this file.
28 #ifndef __OgreWorkQueue_H__
29 #define __OgreWorkQueue_H__
228 virtual void startup(
bool forceRestart =
true) = 0;
238 virtual void addRequestHandler(
uint16 channel, RequestHandler* rh) = 0;
240 virtual void removeRequestHandler(
uint16 channel, RequestHandler* rh) = 0;
251 virtual void addResponseHandler(
uint16 channel, ResponseHandler* rh) = 0;
253 virtual void removeResponseHandler(
uint16 channel, ResponseHandler* rh) = 0;
272 virtual RequestID addRequest(
uint16 channel,
uint16 requestType,
const Any& rData,
uint8 retryCount = 0,
273 bool forceSynchronous =
false,
bool idleThread =
false) = 0;
280 virtual void abortRequest(RequestID
id) = 0;
288 virtual void abortRequestsByChannel(
uint16 channel) = 0;
296 virtual void abortPendingRequestsByChannel(
uint16 channel) = 0;
302 virtual void abortAllRequests() = 0;
309 virtual void setPaused(
bool pause) = 0;
311 virtual bool isPaused()
const = 0;
317 virtual void setRequestsAccepted(
bool accept) = 0;
319 virtual bool getRequestsAccepted()
const = 0;
329 virtual void processResponses() = 0;
334 virtual unsigned long getResponseProcessingTimeLimit()
const = 0;
341 virtual void setResponseProcessingTimeLimit(
unsigned long ms) = 0;
345 virtual void shutdown() = 0;
371 const String& getName()
const;
375 virtual size_t getWorkerThreadCount()
const;
382 virtual void setWorkerThreadCount(
size_t c);
393 virtual bool getWorkersCanAccessRenderSystem()
const;
407 virtual void setWorkersCanAccessRenderSystem(
bool access);
416 virtual void _processNextRequest();
419 virtual void _threadMain() = 0;
425 virtual void addRequestHandler(
uint16 channel, RequestHandler* rh);
427 virtual void removeRequestHandler(
uint16 channel, RequestHandler* rh);
429 virtual void addResponseHandler(
uint16 channel, ResponseHandler* rh);
431 virtual void removeResponseHandler(
uint16 channel, ResponseHandler* rh);
434 virtual RequestID addRequest(
uint16 channel,
uint16 requestType,
const Any& rData,
uint8 retryCount = 0,
435 bool forceSynchronous =
false,
bool idleThread =
false);
437 virtual void abortRequest(RequestID
id);
439 virtual void abortRequestsByChannel(
uint16 channel);
441 virtual void abortPendingRequestsByChannel(
uint16 channel);
443 virtual void abortAllRequests();
445 virtual void setPaused(
bool pause);
447 virtual bool isPaused()
const;
449 virtual void setRequestsAccepted(
bool accept);
451 virtual bool getRequestsAccepted()
const;
453 virtual void processResponses();
481 void operator()()
const;
498 : mHandler(handler) {}
524 if (mHandler->canHandleRequest(req, srcQ))
526 response = mHandler->handleRequest(req, srcQ);
559 void processRequestResponse(Request* r,
bool synchronous);
560 Response* processRequest(Request* r);
563 virtual void notifyWorkers() = 0;
565 void addRequestWithRID(RequestID rid,
uint16 channel,
uint16 requestType,
const Any& rData,
uint8 retryCount);
572 bool processIdleRequests();
map< uint16, ResponseHandlerList >::type ResponseHandlerListByChannel
uint16 mChannel
The request channel, as an integer.
ResponseHandlerListByChannel mResponseHandlers
#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.
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.
RequestHandler * getHandler()
Get handler pointer - note, only use this for == comparison or similar, do not attempt to call it as ...
const Request * getRequest() const
Get the request that this is a response to (NB destruction destroys this)
bool mWorkerRenderSystemAccess
String mMessages
Any diagnostic messages.
const Request * mRequest
Pointer to the request that this response is in relation to.
RequestHandlerHolder(RequestHandler *handler)
RequestID getID() const
Get the identifier of this request.
Variant type that can hold Any other type.
General purpose response structure.
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 ~RequestHandler()
RequestQueue mProcessQueue
#define OGRE_LOCK_RW_MUTEX_WRITE(name)
void abortRequest()
Abort the request.
virtual bool canHandleResponse(const Response *res, const WorkQueue *srcQ)
Return whether this handler can process a given response.
uint16 getChannel() const
Get the request channel (top level categorisation)
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
Interface definition for a handler of responses.
list< ResponseHandler * >::type ResponseHandlerList
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
uint8 getRetryCount() const
Get the remaining retry count.
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.
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)
Any mData
The details of the request (user defined)
list< RequestHandlerHolderPtr >::type RequestHandlerList
Response * handleRequest(const Request *req, const WorkQueue *srcQ)
Process a request if possible.
WorkerFunc(DefaultWorkQueueBase *q)
#define OGRE_RW_MUTEX(name)
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...
DefaultWorkQueueBase * mQueue
virtual bool canHandleRequest(const Request *req, const WorkQueue *srcQ)
Return whether this handler can process a given request.
deque< Request * >::type RequestQueue
Copyright © 2012 Torus Knot Software Ltd

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