thread_exceptions_pos.hpp
Go to the documentation of this file.
00001 
00008 /*****************************************************************************
00009 ** Ifdefs
00010 *****************************************************************************/
00011 
00012 #ifndef ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_
00013 #define ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_
00014 
00015 /*****************************************************************************
00016 ** Platform Check
00017 *****************************************************************************/
00018 
00019 #include <ecl/config/ecl.hpp>
00020 #if defined(ECL_IS_POSIX)
00021 
00022 /*****************************************************************************
00023 ** Includes
00024 *****************************************************************************/
00025 
00026 #include <string>
00027 #include <errno.h>
00028 #include <ecl/errors/handlers.hpp>
00029 
00030 /*****************************************************************************
00031 ** Namespaces
00032 *****************************************************************************/
00033 
00034 namespace ecl {
00035 namespace threads {
00036 
00037 /*****************************************************************************
00038 ** Interface [Errors]
00039 *****************************************************************************/
00047 inline Error ECL_LOCAL handlePthreadCreateError(int error_result) {
00048         switch (error_result) {
00049                 case ( EINVAL ) : return Error(InvalidInputError);
00050                 case ( EAGAIN ) : return Error(MemoryError);
00051                 case ( EPERM )  : return Error(PermissionsError);
00052                 default         : return Error(UnknownError);
00053         }
00054 }
00055 }; // namespace threads
00056 }; // namespace ecl
00057 
00058 /*****************************************************************************
00059 ** Interface [Exceptions]
00060 *****************************************************************************/
00061 
00062 #include <ecl/exceptions/macros.hpp>
00063 #if defined(ECL_HAS_EXCEPTIONS)
00064 
00065 /*****************************************************************************
00066 ** Includes
00067 *****************************************************************************/
00068 
00069 #include <string>
00070 #include <ecl/exceptions/standard_exception.hpp>
00071 
00072 /*****************************************************************************
00073 ** Namespaces
00074 *****************************************************************************/
00075 
00076 namespace ecl {
00077 namespace threads {
00078 
00079 /*****************************************************************************
00080 ** Functions
00081 *****************************************************************************/
00089 inline StandardException ECL_LOCAL throwPthreadCreateException(const char* loc, int error_result) {
00090         switch (error_result) {
00091                 case ( EINVAL ) : return StandardException(loc, InvalidInputError, "Invalid settings in 'attr'");
00092                 case ( EAGAIN ) : return StandardException(loc, MemoryError, "Insufficient resources to create another thread.");
00093                 case ( EPERM )  : return StandardException(loc, PermissionsError, "No permission to set the scheduling policy and parameters specified in attr.");
00094                 default         : return StandardException(loc, UnknownError, "Unknown error.");
00095         }
00096 }
00097 
00104 inline StandardException ECL_LOCAL throwPthreadJoinException(const char* loc, int error_result) {
00105         switch (error_result) {
00106                 case ( EDEADLK ) : return StandardException(loc, UsageError, "Deadlock! Two threads tried to join each other or a thread tried to join itself.");
00107                 case ( EINVAL )  : return StandardException(loc, InvalidInputError, "The specified thread is not joinable or another thread is already waiting to join with it.");
00108                 case ( ESRCH )   : return StandardException(loc, InvalidInputError, "The specified thread (id) could not be found. Probably its already been joined?");
00109                 default          : return StandardException(loc, UnknownError, "Unknown error.");
00110         }
00111 }
00118 inline StandardException ECL_LOCAL throwPthreadCancelException(const char* loc, int error_result) {
00119         switch (error_result) {
00120                 case ( ESRCH )   : return StandardException(loc, InvalidInputError, "The specified thread (id) could not be found. Probably its already terminated.");
00121                 default          : return StandardException(loc, UnknownError, "Unknown error.");
00122         }
00123 }
00124 
00125 }; // namespace threads
00126 }; // namespace ecl
00127 
00128 #endif /* ECL_HAS_EXCEPTIONS */
00129 #endif /* ECL_IS_POSIX */
00130 #endif /* ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_ */


ecl_threads
Author(s): Daniel Stonier
autogenerated on Wed Aug 26 2015 11:27:22