source: flair-dev/trunk/include/FlairCore/Semaphore.h@ 62

Last change on this file since 62 was 62, checked in by Sanahuja Guillaume, 4 years ago

m

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 /*!
34 * \brief Constructor
35 *
36 * Construct a semaphore.
37 *
38 * \param parent parent
39 * \param name name
40 */
41 Semaphore(const Object *parent, uint32_t initialValue, std::string name = "");
42
43 /*!
44 * \brief Destructor
45 *
46 */
47 ~Semaphore();
48
49 /*!
50 * \brief TryGetSemaphore
51 *
52 * Lock the semaphore. If not possible immediately returns false
53 *
54 */
55 bool TryGetSemaphore() const;
56
57 /*!
58 * \brief GetSemaphore
59 *
60 * Lock the semaphore.
61 *
62 * \param timeout The timeout, in nanoseconds.
63 */
64 bool GetSemaphore(Time timeout = TIME_INFINITE) const;
65
66 /*!
67 * \brief ReleaseSemaphore
68 *
69 * Unlock the semaphore.
70 *
71 */
72 bool ReleaseSemaphore(void) const;
73
74private:
75 class Semaphore_impl *pimpl_;
76};
77
78} // end namespace core
79} // end namespace flair
80
81#endif // SEMAPHORE_H
Note: See TracBrowser for help on using the repository browser.