.. _program_listing_file__tmp_ws_src_ecl_core_ecl_threads_include_ecl_threads_thread_exceptions_pos.hpp: Program Listing for File thread_exceptions_pos.hpp ================================================== |exhale_lsh| :ref:`Return to documentation for file ` (``/tmp/ws/src/ecl_core/ecl_threads/include/ecl/threads/thread_exceptions_pos.hpp``) .. |exhale_lsh| unicode:: U+021B0 .. UPWARDS ARROW WITH TIP LEFTWARDS .. code-block:: cpp /***************************************************************************** ** Ifdefs *****************************************************************************/ #ifndef ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_ #define ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_ /***************************************************************************** ** Platform Check *****************************************************************************/ #include #if defined(ECL_IS_POSIX) /***************************************************************************** ** Includes *****************************************************************************/ #include #include #include /***************************************************************************** ** Namespaces *****************************************************************************/ namespace ecl { namespace threads { /***************************************************************************** ** Interface [Errors] *****************************************************************************/ inline Error ECL_LOCAL handlePthreadCreateError(int error_result) { switch (error_result) { case ( EINVAL ) : return Error(InvalidInputError); case ( EAGAIN ) : return Error(MemoryError); case ( EPERM ) : return Error(PermissionsError); default : return Error(UnknownError); } } } // namespace threads } // namespace ecl /***************************************************************************** ** Interface [Exceptions] *****************************************************************************/ #include #if defined(ECL_HAS_EXCEPTIONS) /***************************************************************************** ** Includes *****************************************************************************/ #include #include /***************************************************************************** ** Namespaces *****************************************************************************/ namespace ecl { namespace threads { /***************************************************************************** ** Functions *****************************************************************************/ inline StandardException ECL_LOCAL throwPthreadCreateException(const char* loc, int error_result) { switch (error_result) { case ( EINVAL ) : return StandardException(loc, InvalidInputError, "Invalid settings in 'attr'"); case ( EAGAIN ) : return StandardException(loc, MemoryError, "Insufficient resources to create another thread."); case ( EPERM ) : return StandardException(loc, PermissionsError, "No permission to set the scheduling policy and parameters specified in attr."); default : return StandardException(loc, UnknownError, "Unknown error."); } } inline StandardException ECL_LOCAL throwPthreadJoinException(const char* loc, int error_result) { switch (error_result) { case ( EDEADLK ) : return StandardException(loc, UsageError, "Deadlock! Two threads tried to join each other or a thread tried to join itself."); case ( EINVAL ) : return StandardException(loc, InvalidInputError, "The specified thread is not joinable or another thread is already waiting to join with it."); case ( ESRCH ) : return StandardException(loc, InvalidInputError, "The specified thread (id) could not be found. Probably its already been joined?"); default : return StandardException(loc, UnknownError, "Unknown error."); } } inline StandardException ECL_LOCAL throwPthreadCancelException(const char* loc, int error_result) { switch (error_result) { case ( ESRCH ) : return StandardException(loc, InvalidInputError, "The specified thread (id) could not be found. Probably its already terminated."); default : return StandardException(loc, UnknownError, "Unknown error."); } } } // namespace threads } // namespace ecl #endif /* ECL_HAS_EXCEPTIONS */ #endif /* ECL_IS_POSIX */ #endif /* ECL_THREADS_THREAD_EXCEPTIONS_POS_HPP_ */