1 #include <lib/base/thread.h>
5 #include <lib/base/eerror.h>
7 void eThread::thread_completed(void *ptr)
9 eThread *p = (eThread*) ptr;
10 eDebug("thread has completed..");
15 void *eThread::wrapper(void *ptr)
17 eThread *p = (eThread*)ptr;
19 pthread_cleanup_push( thread_completed, (void*)p );
22 pthread_cleanup_pop(0);
30 void eThread::run( int prio, int policy )
33 pthread_attr_init(&attr);
37 p.__sched_priority=prio;
38 pthread_attr_setschedpolicy(&attr, policy );
39 pthread_attr_setschedparam(&attr, &p);
41 pthread_create(&the_thread, &attr, wrapper, this);
44 while(!alive && timeout--)
46 eDebug("waiting for thread start...");
50 eDebug("thread couldn't be started !!!");
59 void eThread::sendSignal(int sig)
62 pthread_kill( the_thread, sig );
64 eDebug("send signal to non running thread");
67 void eThread::kill(bool hard)
71 eDebug("kill.. but thread don't running");
77 eDebug("killing the thread...");
78 pthread_cancel(the_thread);
83 eDebug("waiting for thread shutdown...");
84 pthread_join(the_thread, 0);