cpp-pthread  (v1.7.3)
Simple C++ wrapper to pthread functions.
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Modules Pages
exceptions.cpp
1 //
2 // exceptions.hpp
3 // cpp-pthread
4 //
5 // Created by herbert koelman on 18/03/2016.
6 //
7 //
8 
9 #include "pthread/exceptions.hpp"
10 
11 namespace pthread {
12 
13  using namespace std ;
14 
15  pthread_exception::pthread_exception( const string &message, const int pthread_errno ): _message(message), _pthread_errno(pthread_errno){
16  };
17 
18  pthread_exception::~pthread_exception(){
19  // Intentionally unimplemented...
20  };
21 
22 #if __cplusplus < 201103L
23  const char *pthread_exception::what() const throw() {
24  return _message.c_str();
25  };
26 #else
27  const char *pthread_exception::what() const noexcept {
28  return _message.c_str();
29  };
30 #endif
31 
33  return _pthread_errno ;
34  };
35 
37  return strerror(_pthread_errno );
38  };
39 
40  // timeout_exception -----------------------------
41  //
42  timeout_exception::timeout_exception(const string &message): pthread_exception(message, ETIMEDOUT){
43  };
44 
45  // mutex exception -----------------------------
46  //
47  mutex_exception::mutex_exception( const std::string &message, const int pthread_error): pthread_exception(message, pthread_error) {
48  };
49 
50  // read_write_lock exception -----------------------------
51  //
52  read_write_lock_exception::read_write_lock_exception( const std::string &message, const int pthread_error): pthread_exception(message, pthread_error) {
53  };
54 
55  // condition_variable_exception -----------------------------
56  //
57  condition_variable_exception::condition_variable_exception( const std::string &message, const int pthread_error): pthread_exception(message, pthread_error){
58  };
59 
60  // thread exception -----------------------------
61  //
62  thread_exception::thread_exception(const string &message, const int pthread_error): pthread_exception(message, pthread_error){
63  }
64 
65  namespace util {
66 
67  // synchonized queue
68  //
69  queue_exception::queue_exception(const std::string &msg): _message(msg){
70  };
71 
72 #if __cplusplus < 201103L
73  const char *queue_exception::what() const throw(){
74 #else
75  const char *queue_exception::what() const noexcept {
76 #endif
77  return _message.c_str();
78  };
79 
80  queue_full::queue_full(const std::string &msg): queue_exception(msg){
81  };
82 
83  queue_timeout::queue_timeout(const std::string &msg): queue_exception(msg){
84  };
85  }; //namespace util
86 } // namespace pthread
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