sttcl  v0.9c
STTCL C++ template state machine framework
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
SttclPosixSemaphore.h
Go to the documentation of this file.
1 
25 #ifndef STTCLPOSIXSEMAPHORE_H_
26 #define STTCLPOSIXSEMAPHORE_H_
27 
28 #if defined(STTCL_POSIX_THREADS) or defined(STTCL_POSIX_IMPL)
29 
30 #include <semaphore.h>
31 #include "../include/SttclTime.h"
32 
33 namespace sttcl
34 {
35 
36 namespace internal
37 {
38 namespace posix_impl
39 {
43 class SttclPosixSemaphore
44 {
45 public:
46  typedef sem_t NativeSemaphoreType;
47 
48  SttclPosixSemaphore(unsigned int initialCount);
49  virtual ~SttclPosixSemaphore();
50 
51  void wait();
52  bool try_wait(const TimeDuration<>& timeout);
53  void post();
54 
55 private:
56  NativeSemaphoreType semaphore;
57 };
58 
59 }
60 }
61 }
62 
63 #endif
64 #endif /* STTCLPOSIXSEMAPHORE_H_ */