34 pthread_attr_t *attr =
new pthread_attr_t;
36 pthread_attr_init(attr);
42 CPU_SET(affinity, &cpuset);
43 pthread_attr_setaffinity_np(attr,
sizeof(cpu_set_t), &cpuset);
45 Warning(
"Run",
"Affinity setting not yet implemented on this platform");
50 det = (th->
fDetached) ? PTHREAD_CREATE_DETACHED : PTHREAD_CREATE_JOINABLE;
52 pthread_attr_setdetachstate(attr, det);
56 const size_t requiredStackSize = 1024*1024*2;
58 if (!pthread_attr_getstacksize(attr, &stackSize)
59 && stackSize < requiredStackSize) {
60 pthread_attr_setstacksize(attr, requiredStackSize);
65 pthread_attr_destroy(attr);
79 return pthread_join((pthread_t) th->
fId,
ret);
98 return pthread_cancel((pthread_t) th->
fId);
107 return pthread_setcancelstate(PTHREAD_CANCEL_DISABLE,
nullptr);
116 return pthread_setcancelstate(PTHREAD_CANCEL_ENABLE,
nullptr);
126 return pthread_setcanceltype(PTHREAD_CANCEL_ASYNCHRONOUS,
nullptr);
136 return pthread_setcanceltype(PTHREAD_CANCEL_DEFERRED,
nullptr);
145 pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &istate);
146 pthread_testcancel();
147 pthread_setcancelstate(istate,
nullptr);
158 if (!
free)
Error(
"CleanUpPush",
"cleanup rountine = 0");
172 if (!
l->fRoutine)
Error(
"CleanUpPop",
"cleanup routine = 0");
173 if (exe &&
l->fRoutine) ((void (*)(
void*))(
l->fRoutine))(
l->fArgument);
174 *
main =
l->fNext;
delete l;
194 return (
Long_t) pthread_self();
int Int_t
Signed integer 4 bytes (int).
long Long_t
Signed long integer 4 bytes (long). Size depends on architecture.
virtual void Warning(const char *method, const char *msgfmt,...) const
Issue warning message.
virtual void Error(const char *method, const char *msgfmt,...) const
Issue error message.
virtual void Info(const char *method, const char *msgfmt,...) const
Issue info message.
TPosixThreadCleanUp(void **main, void *routine, void *arg)
cleanup function
TPosixThreadCleanUp * fNext
Int_t SetCancelOn() override
Turn on the cancellation state of the calling thread.
Int_t SetCancelOff() override
Turn off the cancellation state of the calling thread.
Int_t SetCancelAsynchronous() override
Set the cancellation response type of the calling thread to asynchronous, i.e.
Int_t CleanUpPop(void **main, Int_t exe) override
Pop thread cleanup function from stack.
Int_t Kill(TThread *th) override
Cancellation is the mechanism by which a thread can terminate the execution of another thread.
Int_t CleanUpPush(void **main, void *free, void *arg) override
Add thread cleanup function.
Int_t CleanUp(void **main) override
Default thread cleanup routine.
Int_t Exit(void *ret) override
Terminates the execution of the calling thread. Return 0.
Int_t SetCancelDeferred() override
Set the cancellation response type of the calling thread to deferred, i.e.
Int_t Run(TThread *th, const int affinity=-1) override
Create a pthread.
Long_t SelfId() override
Return the thread identifier for the calling thread.
Int_t Join(TThread *th, void **ret) override
Join suspends the execution of the calling thread until the thread identified by th terminates,...
Int_t CancelPoint() override
Introduce an explicit cancellation point. Returns 0.
<div class="legacybox"><h2>Legacy Code</h2> TThread is a legacy interface: there will be no bug fixes...
static void * Function(void *ptr)
Static method which is called by the system thread function and which in turn calls the actual user f...
int main(int argc, char **argv)