34 pthread_attr_t *attr =
new pthread_attr_t;
36 pthread_attr_init(attr);
39 det = (th->fDetached) ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE;
41 pthread_attr_setdetachstate(attr, det);
45 const size_t requiredStackSize = 1024*1024*2;
47 if (!pthread_attr_getstacksize(attr, &stackSize)
48 && stackSize < requiredStackSize) {
49 pthread_attr_setstacksize(attr, requiredStackSize);
52 if (!ierr) th->fId = (
Long_t)
id;
54 pthread_attr_destroy(attr);
68 return pthread_join((pthread_t) th->
fId, ret);
87 return pthread_cancel((pthread_t) th->
fId);
96 return pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, 0);
105 return pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, 0);
115 return pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS, 0);
125 return pthread_setcanceltype (PTHREAD_CANCEL_DEFERRED, 0);
134 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &istate);
135 pthread_testcancel();
136 pthread_setcancelstate(istate, 0);
147 if (!free)
Error(
"CleanUpPush",
"cleanup rountine = 0");
159 if (!main || !*main)
return 1;
161 if (!l->
fRoutine)
Error(
"CleanUpPop",
"cleanup routine = 0");
163 *main = l->
fNext;
delete l;
173 Info(
"Cleanup",
"cleanup 0x%lx", (
Long_t)*main);
183 return (
Long_t) pthread_self();
196 fRoutine = routine; fArgument = arg;
virtual Int_t CancelPoint()
Introduce an explicit cancellation point. Returns 0.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
virtual Int_t CleanUp(void **main)
Default thread cleanup routine.
virtual Int_t SetCancelOn()
Turn on the cancellation state of the calling thread.
virtual Int_t Exit(void *ret)
Terminates the execution of the calling thread. Return 0.
virtual Long_t SelfId()
Return the thread identifier for the calling thread.
virtual Int_t SetCancelDeferred()
Set the cancellation response type of the calling thread to deferred, i.e.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
TPosixThreadCleanUp(void **main, void *routine, void *arg)
cleanup function
virtual Int_t Kill(TThread *th)
Cancellation is the mechanism by which a thread can terminate the execution of another thread...
typedef void((*Func_t)())
virtual Int_t Join(TThread *th, void **ret)
Join suspends the execution of the calling thread until the thread identified by th terminates...
TPosixThreadCleanUp * fNext
virtual Int_t CleanUpPush(void **main, void *free, void *arg)
Add thread cleanup function.
virtual Int_t SetCancelAsynchronous()
Set the cancellation response type of the calling thread to asynchronous, i.e.
int main(int argc, char **argv)
virtual Int_t SetCancelOff()
Turn off the cancellation state of the calling thread.
static void * Function(void *ptr)
Static method which is called by the system thread function and which in turn calls the actual user f...
virtual Int_t CleanUpPop(void **main, Int_t exe)
Pop thread cleanup function from stack.