FRI-OS
cond_attr.hpp
Go to the documentation of this file.
1 
4 #ifndef __FRIOS_POSIX_THREADS_COND_ATTR_HPP__
5 #define __FRIOS_POSIX_THREADS_COND_ATTR_HPP__
6 
7 #include <frios/utils/unique.hpp>
8 #include <frios/posix/error.hpp>
9 
10 #include <pthread.h>
11 
12 namespace frios {
13 namespace posix {
14 
15 class cond;
16 
18 class cond_attr
19 {
20 private:
21  friend class cond;
22 
24 
25  cond_attr(const cond_attr&) = delete;
26 public:
28  struct init_error : error
29  {
30  init_error(int error_code)
31  : error(error_code)
32  { }
33  };
34 
36  cond_attr(void)
37  {
38  int fail = pthread_condattr_init(&_attr);
39  if(fail) throw init_error(fail);
40  }
41 
44  : _attr(std::move(tmp._attr))
45  { }
46 
48  ~cond_attr(void)
49  {
50  if(_attr.valid())
51  pthread_condattr_destroy(&_attr);
52  }
53  // TODO
54 };
55 
56 } // namespace posix
57 } // namespace frios
58 
59 #endif // include guard
Wrapper around POSIX condition variable attributes.
Definition: cond_attr.hpp:18
Wraper around POSIX condition variables.
Definition: cond.hpp:18
Base class for all POSIX exceptions.
Definition: error.hpp:14
~cond_attr(void)
Destructor frees any resources related to the attributes.
Definition: cond_attr.hpp:48
Exception class for condition initialization errors.
Definition: cond_attr.hpp:28
Utility for ensuring uniqueness of a variable.
cond_attr(cond_attr &&tmp)
Condition variable attributes are movable.
Definition: cond_attr.hpp:43
cond_attr(void)
Default construction.
Definition: cond_attr.hpp:36
Declaration of exception classes for POSIX errors.
error(int error_code)
Construction from POSIX error code.
Definition: error.hpp:26