28 #ifndef __OgreWorkQueue_H__ 29 #define __OgreWorkQueue_H__ 115 RequestID
getID()
const {
return mID; }
228 virtual void startup(
bool forceRestart =
true) = 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;
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();
void abortRequest() const
Set the abort flag.
unsigned long long int RequestID
Numeric identifier for a request.
list< RequestHandlerHolderPtr >::type RequestHandlerList
RequestHandler * getHandler()
Get handler pointer - note, only use this for == comparison or similar, do not attempt to call it as ...
RequestID mID
Identifier (assigned by the system)
const Request * mRequest
Pointer to the request that this response is in relation to.
SharedPtr< RequestHandlerHolder > RequestHandlerHolderPtr
map< uint16, RequestHandlerList >::type RequestHandlerListByChannel
virtual bool canHandleResponse(const Response *res, const WorkQueue *srcQ)
Return whether this handler can process a given response.
RequestHandlerHolder(RequestHandler *handler)
RequestQueue mIdleRequestQueue
Interface to a general purpose request / response style background work queue.
map< String, uint16 >::type ChannelMap
virtual bool canHandleRequest(const Request *req, const WorkQueue *srcQ)
Return whether this handler can process a given request.
deque< Response * >::type ResponseQueue
WorkerFunc(DefaultWorkQueueBase *q)
bool getAborted() const
Get the abort flag.
size_t mWorkerThreadCount
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 setResponseProcessingTimeLimit(unsigned long ms)
Set the time limit imposed on the processing of responses in a single frame, in milliseconds (0 indic...
RequestID getID() const
Get the identifier of this request.
void abortRequest()
Abort the request.
Variant type that can hold Any other type.
uint8 mRetryCount
Retry count - set this to non-zero to have the request try again on failure.
#define OGRE_LOCK_RW_MUTEX_WRITE(name)
String mMessages
Any diagnostic messages.
RequestQueue mRequestQueue
virtual bool isShuttingDown() const
Returns whether the queue is trying to shut down.
General purpose request structure.
bool mWorkerRenderSystemAccess
Any mData
Data associated with the result of the process.
bool succeeded() const
Return whether this is a successful response.
General purpose response structure.
#define OGRE_RW_MUTEX(name)
DefaultWorkQueueBase * mQueue
RequestHandlerListByChannel mRequestHandlers
virtual ~RequestHandler()
uint8 getRetryCount() const
Get the remaining retry count.
uint16 mType
The request type, as an integer within the channel (user can define enumerations on this) ...
deque< Request * >::type RequestQueue
RequestQueue mProcessQueue
uint16 getChannel() const
Get the request channel (top level categorisation)
ResponseHandlerListByChannel mResponseHandlers
unsigned long mResposeTimeLimitMS
uint16 getType() const
Get the type of this request within the given channel.
Base for a general purpose request / response style background work queue.
#define OGRE_LOCK_RW_MUTEX_READ(name)
const Request * getRequest() const
Get the request that this is a response to (NB destruction destroys this)
Response * handleRequest(const Request *req, const WorkQueue *srcQ)
Process a request if possible.
const Any & getData() const
Return the response data (user defined, only valid on success)
Interface definition for a handler of responses.
uint16 mChannel
The request channel, as an integer.
map< uint16, ResponseHandlerList >::type ResponseHandlerListByChannel
Reference-counted shared pointer, used for objects where implicit destruction is required.
ResponseQueue mResponseQueue
RequestHandler * mHandler
Any mData
The details of the request (user defined)
list< ResponseHandler * >::type ResponseHandlerList
const String & getMessages() const
Get any diagnostic messages about the process.
virtual ~ResponseHandler()
Interface definition for a handler of requests.
static const String BLANK
Constant blank string, useful for returning by ref where local does not exist.
Superclass for all objects that wish to use custom memory allocators when their new / delete operator...
const Any & getData() const
Get the user details of this request.
bool mSuccess
Whether the work item succeeded or not.
Intermediate structure to hold a pointer to a request handler which provides insurance against the ha...