source: flair-src/trunk/lib/FlairCore/src/ConditionVariable.h@ 58

Last change on this file since 58 was 15, checked in by Bayard Gildas, 9 years ago

sources reformatted with flair-format-dir script

File size: 2.5 KB
Line 
1// %flair:license{
2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
4// %flair:license}
5/*!
6 * \file ConditionVariable.h
7 * \brief Class defining a condition variable
8 * \author Guillaume Sanahuja, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2014/02/07
10 * \version 4.0
11 */
12
13#ifndef CONDITIONVARIABLE_H
14#define CONDITIONVARIABLE_H
15
16#include <Mutex.h>
17
18class ConditionVariable_impl;
19
20namespace flair {
21namespace core {
22
23/*! \class ConditionVariable
24*
25* \brief Class defining a condition variable
26*
27*/
28
29class ConditionVariable : public Mutex {
30public:
31 /*!
32 * \brief Constructor
33 *
34 * Construct a condition variable with its associated mutex.
35 *
36 * \param parent parent
37 * \param name name
38 */
39 ConditionVariable(const Object *parent, std::string name);
40
41 /*!
42 * \brief Destructor
43 *
44 */
45 ~ConditionVariable();
46
47 /*!
48 * \brief Block on the condition variable
49 *
50 * This method must be called with mutex locked (see Mutex::GetMutex) by the
51 *calling thread or undefined behaviour will result. \n
52 * It atomically releases mutex and causes the calling thread to block on the
53 *condition variable. \n
54 * Only one thread can be blocked at the same time. \n
55 * Upon successful return, the mutex has been locked and is owned by the
56 *calling thread which should unlock it (see Mutex::ReleaseMutex).
57 */
58 void CondWait(void);
59
60 /*!
61 * \brief Block on the condition variable with a timeout
62 *
63 * This method must be called with mutex locked (see Mutex::GetMutex) by the
64 *calling thread or undefined behaviour will result. \n
65 * It atomically releases mutex and causes the calling thread to block on the
66 *condition variable. \n
67 * Only one thread can be blocked at the same time. \n
68 * Upon successful return, the mutex has been locked and is owned by the
69 *calling thread which should unlock it (see Mutex::ReleaseMutex).
70 *
71 * \param date absolute date
72 * \return true if the condition variable is signaled before the date specified
73 *in parameter elapses, false otherwise
74 */
75 bool CondWaitUntil(Time date);
76
77 /*!
78 * \brief Unblock threads blocked on the condition variable
79 *
80 * This method should be called with mutex locked (see Mutex::GetMutex) by the
81 *calling thread. \n
82 * In this case, upon return, the calling thread should unlock the mutex (see
83 *Mutex::ReleaseMutex).
84 *
85 */
86 void CondSignal(void);
87
88private:
89 class ConditionVariable_impl *pimpl_;
90};
91
92} // end namespace core
93} // end namespace flair
94
95#endif // CONDITIONVARIABLE_H
Note: See TracBrowser for help on using the repository browser.