cpp-pthread  (v1.7.3)
Simple C++ wrapper to pthread functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
exceptions.hpp
1 //
2 // exceptions.hpp
3 // cpp-pthread
4 //
5 // Created by herbert koelman on 18/03/2016.
6 //
7 //
8 
9 #ifndef PTHREAD_EXCEPTIONS_HPP
10 #define PTHREAD_EXCEPTIONS_HPP
11 
12 #include <pthread.h>
13 
14 #include <cerrno>
15 #include <string> // std::string
16 #include <cstring>
17 #include <exception> // std::exception
18 
19 
20 namespace pthread {
21 
22 // using namespace std ;
23 
35  class pthread_exception: public std::exception {
36 
37  public:
38 
43  pthread_exception( const std::string &message, const int pthread_errno = -1 );
44 
45  virtual ~pthread_exception();
46 
48 #if __cplusplus < 201103L
49  virtual const char *what() const throw() ;
50 #else
51  virtual const char *what() const noexcept override ;
52 #endif
53 
55  virtual int pthread_errno() ;
56 
58  virtual const char *pthread_errmsg() ;
59 
60  private:
61  std::string _message;
62  //const char *_message;
63  int _pthread_errno;
64 
65  };
66 
70  public:
75  explicit timeout_exception(const std::string &message);
76 
77  };
78 
82  public:
83 
89  explicit mutex_exception( const std::string &message, const int pthread_errno = -1) ;
90 
91  };
92 
96  public:
97 
103  explicit read_write_lock_exception( const std::string &message, const int pthread_errno = -1) ;
104 
105  };
106 
110  public:
111 
117  condition_variable_exception( const std::string &message, const int pthread_errno = -1);
118 
119  virtual ~condition_variable_exception(){
120  // Intentionally unimplemented...
121  };
122  };
123 
126  public:
131  thread_exception(const std::string &message, const int pthread_error = -1);
132  };
133 
134  namespace util {
135 
143  class queue_exception : public std::exception {
144  public:
150  explicit queue_exception(const std::string &msg = "queue_error occured.");
151 
152  virtual ~queue_exception(){
153  // intintional...
154  };
155 
158 #if __cplusplus < 201103L
159  virtual const char *what() const throw();
160 #else
161  virtual const char *what() const noexcept override;
162 #endif
163 
164  protected:
165  std::string _message;
166  };
167 
171  public:
177  explicit queue_full(const std::string &msg = "synchronized_queue full.");
178 
179  };
180 
184  public:
190  explicit queue_timeout(const std::string &msg = "synchronized_queue get/put timed out.");
191 
192  };
194  }; // namespace util
195 
198 } // namespace pthread
199 
200 #endif
virtual int pthread_errno()
Definition: exceptions.cpp:32
mutex_exception(const std::string &message, const int pthread_errno=-1)
Definition: exceptions.cpp:47
std::string _message
message buffer
Definition: exceptions.hpp:165
virtual const char * what() const noexceptoverride
Definition: exceptions.cpp:27
queue_timeout(const std::string &msg="synchronized_queue get/put timed out.")
Definition: exceptions.cpp:83
condition_variable_exception(const std::string &message, const int pthread_errno=-1)
Definition: exceptions.cpp:57
virtual const char * what() const noexceptoverride
Definition: exceptions.cpp:75
pthread_exception(const std::string &message, const int pthread_errno=-1)
Definition: exceptions.cpp:15
timeout_exception(const std::string &message)
Definition: exceptions.cpp:42
thread_exception(const std::string &message, const int pthread_error=-1)
Definition: exceptions.cpp:62
read_write_lock_exception(const std::string &message, const int pthread_errno=-1)
Definition: exceptions.cpp:52
queue_full(const std::string &msg="synchronized_queue full.")
Definition: exceptions.cpp:80
queue_exception(const std::string &msg="queue_error occured.")
Definition: exceptions.cpp:69
virtual const char * pthread_errmsg()
Definition: exceptions.cpp:36