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

Last change on this file since 439 was 330, checked in by Sanahuja Guillaume, 5 years ago

use less bandwidth in vprnlite

File size: 2.7 KB
RevLine 
[2]1// %flair:license{
[15]2// This file is part of the Flair framework distributed under the
3// CECILL-C License, Version 1.0.
[2]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
[15]20namespace flair {
21namespace core {
[2]22
[15]23/*! \class ConditionVariable
24*
25* \brief Class defining a condition variable
26*
27*/
[2]28
[15]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);
[2]40
[15]41 /*!
42 * \brief Destructor
43 *
44 */
45 ~ConditionVariable();
[2]46
[15]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).
[330]57 *
58 * \param timeout timeout
59 * \return true if the condition variable is signaled before the tipeout specified
60 * in parameter elapses or if timeout elapses, false otherwise
[15]61 */
[330]62 bool CondWait(Time timeout=TIME_INFINITE);
[2]63
[15]64 /*!
65 * \brief Block on the condition variable with a timeout
66 *
67 * This method must be called with mutex locked (see Mutex::GetMutex) by the
68 *calling thread or undefined behaviour will result. \n
69 * It atomically releases mutex and causes the calling thread to block on the
70 *condition variable. \n
71 * Only one thread can be blocked at the same time. \n
72 * Upon successful return, the mutex has been locked and is owned by the
73 *calling thread which should unlock it (see Mutex::ReleaseMutex).
74 *
75 * \param date absolute date
76 * \return true if the condition variable is signaled before the date specified
77 *in parameter elapses, false otherwise
78 */
79 bool CondWaitUntil(Time date);
[2]80
[15]81 /*!
82 * \brief Unblock threads blocked on the condition variable
83 *
84 * This method should be called with mutex locked (see Mutex::GetMutex) by the
85 *calling thread. \n
86 * In this case, upon return, the calling thread should unlock the mutex (see
87 *Mutex::ReleaseMutex).
88 *
89 */
90 void CondSignal(void);
[2]91
[15]92private:
93 class ConditionVariable_impl *pimpl_;
94};
[2]95
96} // end namespace core
97} // end namespace flair
98
99#endif // CONDITIONVARIABLE_H
Note: See TracBrowser for help on using the repository browser.