58 if ((*request)->_dispatched)
63 (*request)->_dispatched =
true;
66 if (!
EventMan.pushEvent((*request)->_event))
78 if (!(*request)->_dispatched) {
89 (*request)->_hasReply.lock();
97 (*request)->copyToReply();
100 (*request)->setGarbage();
109 (*request)->setGarbage();
131 (*rID)->_glContainer.glContainer = &glContainer;
139 (*rID)->_glContainer.glContainer = &glContainer;
155 (*rID)->_callInMainThread.caller = &caller;
177 while (!
_killThread.load(boost::memory_order_relaxed)) {
Generic image decoder interface.
Inter-thread request events.
Request the rebuilding of a GL container.
T callInMainThread(const MainThreadFunctor< T > &f)
Call this function in the main thread.
The request manager, handling all requests.
bool isMainThread()
Returns true if called from the main thread, false otherwise.
boost::atomic< bool > _killThread
void dispatchAndWait(RequestID request)
Dispatch a request and wait for the answer.
static bool requestIsGarbage(const Request *const request)
Exception that provides a stack of explanations.
Common::Mutex _mutexUse
The mutex locking the use of the manager.
Basic exceptions to throw.
Threading system helpers.
bool createThread(const UString &name="")
Utility templates and functions.
void remove_if(Predicate pred)
RequestID rebuild(Graphics::GLContainer &glContainer)
Request that a GL container shall be rebuilt.
#define DECLARE_SINGLETON(T)
Note that you need to use this macro from the global namespace.
The global events manager.
ITCEvent
Specific type of the inter-thread communication.
Request the destruction of a GL container.
RequestList::iterator RequestID
boost::function< void()> MainThreadCallerFunctor
Convenience class that locks a mutex on creation and unlocks it on destruction.
#define EventMan
Shortcut for accessing the events manager.
void dispatch(RequestID request)
Dispatch a request.
RequestList _requests
All currently active requests.
void sync()
Request a sync, letting all prior requests finish.
RequestID newRequest(ITCEvent type)
Create a new, empty request of that type.
A request, carrying inter-thread communication.
A container of OpenGL elements.
void forget(RequestID request)
Ignore any answer we get.
void dispatchAndForget(RequestID request)
Dispatch a request and ignore the answer.
void waitReply(RequestID request)
Wait for a request to be answered.
Request to call a function in the main thread.
Request a sync, letting all prior requests finish.