28 #ifndef __OgreWorkQueue_H__
29 #define __OgreWorkQueue_H__
114 RequestID
getID()
const {
return mID; }
227 virtual void startup(
bool forceRestart =
true) = 0;
237 virtual void addRequestHandler(
uint16 channel, RequestHandler* rh) = 0;
239 virtual void removeRequestHandler(
uint16 channel, RequestHandler* rh) = 0;
250 virtual void addResponseHandler(
uint16 channel, ResponseHandler* rh) = 0;
252 virtual void removeResponseHandler(
uint16 channel, ResponseHandler* rh) = 0;
266 virtual RequestID addRequest(
uint16 channel,
uint16 requestType,
const Any& rData,
uint8 retryCount = 0,
267 bool forceSynchronous =
false) = 0;
274 virtual void abortRequest(RequestID
id) = 0;
281 virtual void abortRequestsByChannel(
uint16 channel) = 0;
287 virtual void abortAllRequests() = 0;
294 virtual void setPaused(
bool pause) = 0;
296 virtual bool isPaused()
const = 0;
302 virtual void setRequestsAccepted(
bool accept) = 0;
304 virtual bool getRequestsAccepted()
const = 0;
314 virtual void processResponses() = 0;
319 virtual unsigned long getResponseProcessingTimeLimit()
const = 0;
326 virtual void setResponseProcessingTimeLimit(
unsigned long ms) = 0;
330 virtual void shutdown() = 0;
356 const String& getName()
const;
360 virtual size_t getWorkerThreadCount()
const;
367 virtual void setWorkerThreadCount(
size_t c);
378 virtual bool getWorkersCanAccessRenderSystem()
const;
392 virtual void setWorkersCanAccessRenderSystem(
bool access);
401 virtual void _processNextRequest();
404 virtual void _threadMain() = 0;
410 virtual void addRequestHandler(
uint16 channel, RequestHandler* rh);
412 virtual void removeRequestHandler(
uint16 channel, RequestHandler* rh);
414 virtual void addResponseHandler(
uint16 channel, ResponseHandler* rh);
416 virtual void removeResponseHandler(
uint16 channel, ResponseHandler* rh);
419 virtual RequestID addRequest(
uint16 channel,
uint16 requestType,
const Any& rData,
uint8 retryCount = 0,
420 bool forceSynchronous =
false);
422 virtual void abortRequest(RequestID
id);
424 virtual void abortRequestsByChannel(
uint16 channel);
426 virtual void abortAllRequests();
428 virtual void setPaused(
bool pause);
430 virtual bool isPaused()
const;
432 virtual void setRequestsAccepted(
bool accept);
434 virtual bool getRequestsAccepted()
const;
436 virtual void processResponses();
479 : mHandler(handler) {}
505 if (mHandler->canHandleRequest(req, srcQ))
507 response = mHandler->handleRequest(req, srcQ);
535 void processRequestResponse(
Request* r,
bool synchronous);
539 virtual
void notifyWorkers() = 0;
541 void addRequestWithRID(RequestID rid,
uint16 channel,
uint16 requestType, const
Any& rData,
uint8 retryCount);
ResponseHandlerListByChannel mResponseHandlers
uint16 getChannel() const
Get the request channel (top level categorisation)
const String & getMessages() const
Get any diagnostic messages about the process.
Any mData
The details of the request (user defined)
Variant type that can hold Any other type.
RequestQueue mRequestQueue
#define OGRE_RW_MUTEX(name)
RequestHandler * mHandler
uint16 mType
The request type, as an integer within the channel (user can define enumerations on this) ...
virtual void setResponseProcessingTimeLimit(unsigned long ms)
Set the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
General purpose request structure.
bool mSuccess
Whether the work item succeeded or not.
map< uint16, ResponseHandlerList >::type ResponseHandlerListByChannel
RequestID mID
Identifier (assigned by the system)
bool mWorkerRenderSystemAccess
General purpose response structure.
unsigned long mResposeTimeLimitMS
map< uint16, RequestHandlerList >::type RequestHandlerListByChannel
list< RequestHandlerHolderPtr >::type RequestHandlerList
Base for a general purpose request / response style background work queue.
ResponseQueue mResponseQueue
RequestHandlerHolder(RequestHandler *handler)
DefaultWorkQueueBase * mQueue
const Any & getData() const
Return the response data (user defined, only valid on success)
#define OGRE_LOCK_RW_MUTEX_READ(name)
virtual bool canHandleResponse(const Response *res, const WorkQueue *srcQ)
Return whether this handler can process a given response.
SharedPtr< RequestHandlerHolder > RequestHandlerHolderPtr
virtual unsigned long getResponseProcessingTimeLimit() const
Get the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
Any mData
Data associated with the result of the process.
WorkerFunc(DefaultWorkQueueBase *q)
RequestHandler * getHandler()
Get handler pointer - note, only use this for == comparison or similar, do not attempt to call it as ...
const Request * mRequest
Pointer to the request that this response is in relation to.
uint16 getType() const
Get the type of this request within the given channel.
virtual bool canHandleRequest(const Request *req, const WorkQueue *srcQ)
Return whether this handler can process a given request.
RequestID getID() const
Get the identifier of this request.
void abortRequest()
Abort the request.
Interface definition for a handler of requests.
Intermediate structure to hold a pointer to a request handler which provides insurance against the ha...
virtual bool isShuttingDown() const
Returns whether the queue is trying to shut down.
std::map< String, uint16 > ChannelMap
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
#define OGRE_LOCK_RW_MUTEX_WRITE(name)
uint8 mRetryCount
Retry count - set this to non-zero to have the request try again on failure.
uint8 getRetryCount() const
Get the remaining retry count.
Interface definition for a handler of responses.
RequestQueue mProcessQueue
deque< Request * >::type RequestQueue
bool getAborted() const
Get the abort flag.
RequestHandlerListByChannel mRequestHandlers
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
void abortRequest() const
Set the abort flag.
list< ResponseHandler * >::type ResponseHandlerList
virtual ~RequestHandler()
unsigned long long int RequestID
Numeric identifier for a request.
Response * handleRequest(const Request *req, const WorkQueue *srcQ)
Process a request if possible.
Reference-counted shared pointer, used for objects where implicit destruction is required.
const Request * getRequest() const
Get the request that this is a response to (NB destruction destroys this)
const Any & getData() const
Get the user details of this request.
size_t mWorkerThreadCount
String mMessages
Any diagnostic messages.
Interface to a general purpose request / response style background work queue.
deque< Response * >::type ResponseQueue
uint16 mChannel
The request channel, as an integer.
virtual ~ResponseHandler()
bool succeeded() const
Return whether this is a successful response.