12 #include <ecl/config/ecl.hpp> 13 #if defined(ECL_IS_POSIX) 20 #include "../../include/ecl/threads/thread_pos.hpp" 21 #include <sys/resource.h> 38 start(
function, priority, stack_size);
49 initialise(stack_size);
51 thread_task =
new threads::ThreadTask< NullaryFreeFunction<void> >(nullary_function_object, priority);
52 int result = pthread_create(&(this->thread_handle), &(this->attrs), threads::ThreadTask< NullaryFreeFunction<void> >::EntryPoint, thread_task);
53 pthread_attr_destroy(&attrs);
58 return threads::handlePthreadCreateError(result);
76 if ( has_started && !join_requested ) {
77 pthread_detach(thread_handle);
80 void Thread::cancel() ecl_debug_throw_decl(StandardException) {
81 int result = pthread_cancel(thread_handle);
85 if ( thread_task != NULL ) {
94 void Thread::join() ecl_debug_throw_decl(StandardException) {
95 join_requested =
true;
96 if( thread_task != NULL ) {
97 int result = pthread_join( thread_handle, 0 );
98 ecl_assert_throw( result == 0, threads::throwPthreadJoinException(LOC,result));
104 pthread_attr_init( &attrs );
108 pthread_attr_setscope(&attrs, PTHREAD_SCOPE_SYSTEM);
110 pthread_attr_setinheritsched(&attrs,PTHREAD_INHERIT_SCHED);
119 pthread_attr_setdetachstate(&attrs,PTHREAD_CREATE_JOINABLE);
124 if ( stack_size != DefaultStackSize ) {
125 int result = pthread_attr_setstacksize(&attrs,stack_size);
126 ecl_assert_throw( result == 0, StandardException(LOC,
ConfigurationError,
"Specified stack size was less than PTHREAD_STACK_MIN or wasn't a multiple of the page size."));
Embedded control libraries.
#define ecl_assert_throw(expression, exception)
#define ecl_assert_throw_decl(exception)
#define ecl_debug_throw_decl(exception)
#define ecl_debug_throw(exception)
NullaryFreeFunction< R > generateFunctionObject(R(*function)())
Priority
Shared abstraction of the scheduling priorities.