MeVisLab Toolbox Reference
mlBackgroundTaskMessageQueue.h
Go to the documentation of this file.
1/*************************************************************************************
2**
3** Copyright 2009, MeVis Medical Solutions AG
4**
5** The user may use this file in accordance with the license agreement provided with
6** the Software or, alternatively, in accordance with the terms contained in a
7** written agreement between the user and MeVis Medical Solutions AG.
8**
9** For further information use the contact form at https://www.mevislab.de/contact
10**
11**************************************************************************************/
12
13#ifndef ML_BACKGROUND_TASK_MESSAGE_QUEUE_H
14#define ML_BACKGROUND_TASK_MESSAGE_QUEUE_H
15
16// Local includes
18
19#include <ThirdPartyWarningsDisable.h>
20#include <deque>
21#include <boost/thread/mutex.hpp>
22#include <boost/thread/condition.hpp>
23#include <ThirdPartyWarningsRestore.h>
24
25ML_START_NAMESPACE
26
27//-----------------------------------------------------------------------
28
29class BackgroundTaskMessage;
30class BackgroundTaskMessageReceiver;
31
33{
35
36public:
39
45
50
55
60 BackgroundTaskMessage* nextMessage(int& availableMessages);
61
67
71
73 bool isCanceled() const { return _isCanceled; }
74
76 void cancel();
77
80
81private:
83 std::deque<BackgroundTaskMessage*> _queue;
85 boost::mutex _mutex;
87 boost::condition _messageAvailable;
88
90 bool _isCanceled;
91};
92
93ML_END_NAMESPACE
94
95#endif
96
97
#define MLBACKGROUNDTASKS_EXPORT
void removeMessagesForReceiver(BackgroundTaskMessageReceiver *receiver)
BackgroundTaskMessage * waitForMessage()
BackgroundTaskMessage * nextMessage()
void cancelAndNotify()
Sets that the queue is canceled and notifies it if it is waiting for new messages.
BackgroundTaskMessage * nextMessage(int &availableMessages)
bool isCanceled() const
Returns whether the queue has been canceled.
void addMessage(BackgroundTaskMessage *message)
BackgroundTaskMessage * nextMessageNoLock()
void cancel()
Sets that the queue is canceled.
The base class of all background messages.
#define ML_DISALLOW_COPY_AND_ASSIGN(className)
Defines basic macros.
Definition mlMacros.h:21