source: flair-src/trunk/lib/FlairCore/src/Semaphore.h@ 300

Last change on this file since 300 was 238, checked in by Bayard Gildas, 6 years ago

correction sémaphore. bloquant tout ça...

File size: 1.4 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 Semaphore.h
7 * \brief Class defining a semaphore
8 * \author Thomas Fuhrmann, Copyright Heudiasyc UMR UTC/CNRS 7253
9 * \date 2016/11/16
10 * \version 1.0
11 */
12
13#ifndef SEMAPHORE_H
14#define SEMAPHORE_H
15
16#include <Object.h>
17
18class Semaphore_impl;
19class ConditionVariable_impl;
20
21namespace flair {
22namespace core {
23
24/*! \class Semaphore
25*
26* \brief Class defining a semaphore
27*
28*/
29class Semaphore : public Object {
30 friend class ::ConditionVariable_impl;
31
32public:
33 enum class Type { anonymous, named };
34 /*!
35 * \brief Constructor
36 *
37 * Construct a semaphore.
38 *
39 * \param parent parent
40 * \param name name
41 */
42 Semaphore(const Object *parent, uint32_t initialValue, std::string name = "", Type type=Type::anonymous);
43
44 /*!
45 * \brief Destructor
46 *
47 */
48 ~Semaphore();
49
50 /*!
51 * \brief TryGetSemaphore
52 *
53 * Lock the semaphore. If not possible immediately returns false
54 *
55 */
56 bool TryGetSemaphore() const;
57
58 /*!
59 * \brief GetSemaphore
60 *
61 * Lock the semaphore.
62 *
63 * \param timeout The timeout, in nanoseconds.
64 */
65 bool GetSemaphore(Time timeout = TIME_INFINITE) const;
66
67 /*!
68 * \brief ReleaseSemaphore
69 *
70 * Unlock the semaphore.
71 *
72 */
73 bool ReleaseSemaphore(void) const;
74
75private:
76 class Semaphore_impl *pimpl_;
77 Type type;
78};
79
80} // end namespace core
81} // end namespace flair
82
83#endif // SEMAPHORE_H
Note: See TracBrowser for help on using the repository browser.