FRI-OS
mutex_attr.hpp
Go to the documentation of this file.
1 
4 #ifndef __FRIOS_POSIX_THREADS_MUTEX_ATTR_HPP__
5 #define __FRIOS_POSIX_THREADS_MUTEX_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 mutex;
16 
19 {
20 private:
21  friend class mutex;
22 
24 
25  mutex_attr(const mutex_attr&) = delete;
26 public:
28 
30  struct init_error : error
31  {
32  init_error(int error_code)
33  : error(error_code)
34  { }
35  };
36 
38 
41  mutex_attr(void)
42  {
43  int fail = pthread_mutexattr_init(&_attr);
44  if(fail) throw init_error(fail);
45  }
46 
49  : _attr(std::move(tmp._attr))
50  { }
51 
54  {
55  if(_attr.valid())
56  pthread_mutexattr_destroy(&_attr);
57  }
58 
59  // TODO
60 };
61 
62 } // namespace posix
63 } // namespace frios
64 
65 #endif // include guard
Exception class for attribute initialization errors.
Definition: mutex_attr.hpp:30
Base class for all POSIX exceptions.
Definition: error.hpp:14
mutex_attr(mutex_attr &&tmp)
Mutex attributes are movable.
Definition: mutex_attr.hpp:48
mutex_attr(void)
Default construction.
Definition: mutex_attr.hpp:41
Wrapper around POSIX mutexes.
Definition: mutex.hpp:21
Utility for ensuring uniqueness of a variable.
Declaration of exception classes for POSIX errors.
~mutex_attr(void)
Destructor releases any resources related to the attributes.
Definition: mutex_attr.hpp:53
error(int error_code)
Construction from POSIX error code.
Definition: error.hpp:26
Wrapper around POSIX condition variable attributes.
Definition: mutex_attr.hpp:18