1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
28
#include <boost/shared_ptr.hpp>
29
#include <boost/function.hpp>
30
#include <boost/signals2/signal.hpp>
31
#include <boost/thread.hpp>
33
#include "WExportCommon.h"
36
* Class to encapsulate boost::condition_variable_any. You may use it to efficiently wait for events (a condition comes true). It
37
* is a very simple implementation. It might be extended easily. Timed wait functions and so on.
39
class OWCOMMON_EXPORT WCondition // NOLINT
41
friend class WCondition_test;
44
* Shared pointer type for WCondition.
46
typedef boost::shared_ptr< WCondition > SPtr;
49
* Const shared pointer type for WCondition.
51
typedef boost::shared_ptr< const WCondition > ConstSPtr;
54
* Default constructor.
61
virtual ~WCondition();
64
* Wait for the condition. Sets the calling thread asleep.
66
virtual void wait() const;
69
* Notifies all waiting threads.
71
virtual void notify();
74
* Type used for signalling condition changes.
76
typedef boost::function0< void > t_ConditionNotifierType;
79
* Subscribes a specified function to be notified on condition change.
81
* \param notifier the notifier function
83
* \return the connection.
85
boost::signals2::connection subscribeSignal( t_ConditionNotifierType notifier );
90
* Type used for condition notification.
92
typedef boost::signals2::signal<void ( void )> t_ConditionSignalType;
95
* Signal getting fired whenever the condition fires.
97
t_ConditionSignalType signal_ConditionFired;
102
mutable boost::condition_variable_any m_condition;
105
* The mutex used for the condition.
107
mutable boost::shared_mutex m_mutex;
112
#endif // WCONDITION_H