thread_exceptions_pos.hpp
Go to the documentation of this file.
1 
8 /*****************************************************************************
9 ** Ifdefs
10 *****************************************************************************/
11 
12 #ifndef ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_
13 #define ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_
14 
15 /*****************************************************************************
16 ** Platform Check
17 *****************************************************************************/
18 
19 #include <ecl/config/ecl.hpp>
20 #if defined(ECL_IS_POSIX)
21 
22 /*****************************************************************************
23 ** Includes
24 *****************************************************************************/
25 
26 #include <string>
27 #include <errno.h>
28 #include <ecl/errors/handlers.hpp>
29 
30 /*****************************************************************************
31 ** Namespaces
32 *****************************************************************************/
33 
34 namespace ecl {
35 namespace threads {
36 
37 /*****************************************************************************
38 ** Interface [Errors]
39 *****************************************************************************/
47 inline Error ECL_LOCAL handlePthreadCreateError(int error_result) {
48  switch (error_result) {
49  case ( EINVAL ) : return Error(InvalidInputError);
50  case ( EAGAIN ) : return Error(MemoryError);
51  case ( EPERM ) : return Error(PermissionsError);
52  default : return Error(UnknownError);
53  }
54 }
55 }; // namespace threads
56 }; // namespace ecl
57 
58 /*****************************************************************************
59 ** Interface [Exceptions]
60 *****************************************************************************/
61 
63 #if defined(ECL_HAS_EXCEPTIONS)
64 
65 /*****************************************************************************
66 ** Includes
67 *****************************************************************************/
68 
69 #include <string>
71 
72 /*****************************************************************************
73 ** Namespaces
74 *****************************************************************************/
75 
76 namespace ecl {
77 namespace threads {
78 
79 /*****************************************************************************
80 ** Functions
81 *****************************************************************************/
89 inline StandardException ECL_LOCAL throwPthreadCreateException(const char* loc, int error_result) {
90  switch (error_result) {
91  case ( EINVAL ) : return StandardException(loc, InvalidInputError, "Invalid settings in 'attr'");
92  case ( EAGAIN ) : return StandardException(loc, MemoryError, "Insufficient resources to create another thread.");
93  case ( EPERM ) : return StandardException(loc, PermissionsError, "No permission to set the scheduling policy and parameters specified in attr.");
94  default : return StandardException(loc, UnknownError, "Unknown error.");
95  }
96 }
97 
104 inline StandardException ECL_LOCAL throwPthreadJoinException(const char* loc, int error_result) {
105  switch (error_result) {
106  case ( EDEADLK ) : return StandardException(loc, UsageError, "Deadlock! Two threads tried to join each other or a thread tried to join itself.");
107  case ( EINVAL ) : return StandardException(loc, InvalidInputError, "The specified thread is not joinable or another thread is already waiting to join with it.");
108  case ( ESRCH ) : return StandardException(loc, InvalidInputError, "The specified thread (id) could not be found. Probably its already been joined?");
109  default : return StandardException(loc, UnknownError, "Unknown error.");
110  }
111 }
118 inline StandardException ECL_LOCAL throwPthreadCancelException(const char* loc, int error_result) {
119  switch (error_result) {
120  case ( ESRCH ) : return StandardException(loc, InvalidInputError, "The specified thread (id) could not be found. Probably its already terminated.");
121  default : return StandardException(loc, UnknownError, "Unknown error.");
122  }
123 }
124 
125 }; // namespace threads
126 }; // namespace ecl
127 
128 #endif /* ECL_HAS_EXCEPTIONS */
129 #endif /* ECL_IS_POSIX */
130 #endif /* ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_ */
Embedded control libraries.
PermissionsError
UnknownError
InvalidInputError
UsageError
MemoryError
#define ECL_LOCAL


ecl_threads
Author(s): Daniel Stonier
autogenerated on Mon Feb 28 2022 22:18:53