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

Last change on this file since 6 was 2, checked in by Sanahuja Guillaume, 9 years ago

flaircore

File size: 2.9 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
21{
22namespace core
23{
24
25 /*! \class ConditionVariable
26 *
27 * \brief Class defining a condition variable
28 *
29 */
30
31 class ConditionVariable: public Mutex
32 {
33 public:
34 /*!
35 * \brief Constructor
36 *
37 * Construct a condition variable with its associated mutex.
38 *
39 * \param parent parent
40 * \param name name
41 */
42 ConditionVariable(const Object* parent,std::string name);
43
44 /*!
45 * \brief Destructor
46 *
47 */
48 ~ConditionVariable();
49
50 /*!
51 * \brief Block on the condition variable
52 *
53 * This method must be called with mutex locked (see Mutex::GetMutex) by the calling thread or undefined behaviour will result. \n
54 * It atomically releases mutex and causes the calling thread to block on the condition variable. \n
55 * Only one thread can be blocked at the same time. \n
56 * Upon successful return, the mutex has been locked and is owned by the 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 calling thread or undefined behaviour will result. \n
64 * It atomically releases mutex and causes the calling thread to block on the condition variable. \n
65 * Only one thread can be blocked at the same time. \n
66 * Upon successful return, the mutex has been locked and is owned by the calling thread which should unlock it (see Mutex::ReleaseMutex).
67 *
68 * \param date absolute date
69 * \return true if the condition variable is signaled before the date specified in parameter elapses, false otherwise
70 */
71 bool CondWaitUntil(Time date);
72
73 /*!
74 * \brief Unblock threads blocked on the condition variable
75 *
76 * This method should be called with mutex locked (see Mutex::GetMutex) by the calling thread. \n
77 * In this case, upon return, the calling thread should unlock the mutex (see Mutex::ReleaseMutex).
78 *
79 */
80 void CondSignal(void);
81
82 private:
83 class ConditionVariable_impl* pimpl_;
84 };
85
86} // end namespace core
87} // end namespace flair
88
89#endif // CONDITIONVARIABLE_H
Note: See TracBrowser for help on using the repository browser.