Flair
Framework Libre Air
Semaphore.h
Go to the documentation of this file.
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}
13 #ifndef SEMAPHORE_H
14 #define SEMAPHORE_H
15 
16 #include <Object.h>
17 
18 class Semaphore_impl;
19 class ConditionVariable_impl;
20 
21 namespace flair {
22 namespace core {
23 
29 class Semaphore : public Object {
30  friend class ::ConditionVariable_impl;
31 
32 public:
33  enum class Type { anonymous, named };
42  Semaphore(const Object *parent, uint32_t initialValue, std::string name = "", Type type=Type::anonymous);
43 
48  ~Semaphore();
49 
56  bool TryGetSemaphore() const;
57 
65  bool GetSemaphore(Time timeout = TIME_INFINITE) const;
66 
73  bool ReleaseSemaphore(void) const;
74 
75 private:
76  class Semaphore_impl *pimpl_;
77  Type type;
78 };
79 
80 } // end namespace core
81 } // end namespace flair
82 
83 #endif // SEMAPHORE_H
Base class for all Framework's classes.
Definition: Object.h:83
namespace of the flair Framework
Definition: Ahrs.h:19
~Semaphore()
Destructor.
unsigned long long Time
Time definition, in ns.
Definition: Object.h:55
Semaphore(const Object *parent, uint32_t initialValue, std::string name="", Type type=Type::anonymous)
Constructor.
bool TryGetSemaphore() const
TryGetSemaphore.
Base class for all Framework's classes.
bool GetSemaphore(Time timeout=TIME_INFINITE) const
GetSemaphore.
Class defining a semaphore.
Definition: Semaphore.h:29
bool ReleaseSemaphore(void) const
ReleaseSemaphore.