13 #ifndef ML_BACKGROUND_TASK_MESSAGE_QUEUE_H
14 #define ML_BACKGROUND_TASK_MESSAGE_QUEUE_H
19 #include <ThirdPartyWarningsDisable.h>
21 #include <boost/thread/mutex.hpp>
22 #include <boost/thread/condition.hpp>
23 #include <ThirdPartyWarningsRestore.h>
29 class BackgroundTaskMessage;
30 class BackgroundTaskMessageReceiver;
79 std::deque<BackgroundTaskMessage*> _queue;
83 boost::condition _messageAvailable;
#define MLBACKGROUNDTASKS_EXPORT
Project global and OS specific declarations.
void removeMessagesForReceiver(BackgroundTaskMessageReceiver *receiver)
Remove all messages for the given receiver.
BackgroundTaskMessageQueue()
BackgroundTaskMessage * nextMessage()
Returns the next message without blocking, returns NULL if no message was available.
void cancelAndNotify()
Sets that the queue is canceled and notifies it if it is waiting for new messages.
~BackgroundTaskMessageQueue()
BackgroundTaskMessage * nextMessage(int &availableMessages)
Returns the next message and the number of available messages (including the returned message) withou...
bool isCanceled() const
Returns if the queue has been canceled.
BackgroundTaskMessage * waitForMessage()
wait for the next message (the returned message is owned by the user and needs to be deleted by the u...
BackgroundTaskMessage * nextMessageNoLock()
Returns the next message without locking the queue (ONLY use for synchronous case!...
void addMessage(BackgroundTaskMessage *message)
put the message into the queue, pass ownership to the queue (do not delete the message!...
void cancel()
Sets that the queue is canceled.
The background task receiver is a light-weight base class which can be inherited (e....
The base class of all background messages.
#define ML_DISALLOW_COPY_AND_ASSIGN(className)
Defines basic macros.