ROOT » CORE » THREAD » TThread

class TThread: public TNamed


TThread

This class implements threads. A thread is an execution environment
much lighter than a process. A single process can have multiple
threads. The actual work is done via the TThreadImp class (either
TPosixThread or TWin32Thread).


Function Members (Methods)

public:
virtual~TThread()
voidTObject::AbstractMethod(const char* method) const
virtual voidTObject::AppendPad(Option_t* option = "")
virtual voidTObject::Browse(TBrowser* b)
static Int_tCancelPoint()
static TClass*Class()
virtual const char*TObject::ClassName() const
static Int_tCleanUp()
static Int_tCleanUpPop(Int_t exe = 0)
static Int_tCleanUpPush(void* free, void* arg = 0)
virtual voidTNamed::Clear(Option_t* option = "")
virtual TObject*TNamed::Clone(const char* newname = "") const
virtual Int_tTNamed::Compare(const TObject* obj) const
virtual voidTNamed::Copy(TObject& named) const
virtual voidDelete(Option_t* option = "")
static Int_tDelete(TThread*& th)
virtual Int_tTObject::DistancetoPrimitive(Int_t px, Int_t py)
virtual voidTObject::Draw(Option_t* option = "")
virtual voidTObject::DrawClass() constMENU
virtual TObject*TObject::DrawClone(Option_t* option = "") constMENU
virtual voidTObject::Dump() constMENU
virtual voidTObject::Error(const char* method, const char* msgfmt) const
virtual voidTObject::Execute(const char* method, const char* params, Int_t* error = 0)
virtual voidTObject::Execute(TMethod* method, TObjArray* params, Int_t* error = 0)
virtual voidTObject::ExecuteEvent(Int_t event, Int_t px, Int_t py)
static Int_tExists()
static Int_tExit(void* ret = 0)
virtual voidTObject::Fatal(const char* method, const char* msgfmt) const
virtual voidTNamed::FillBuffer(char*& buffer)
virtual TObject*TObject::FindObject(const char* name) const
virtual TObject*TObject::FindObject(const TObject* obj) const
virtual Option_t*TObject::GetDrawOption() const
static Long_tTObject::GetDtorOnly()
virtual const char*TObject::GetIconName() const
Long_tGetId() const
virtual const char*TNamed::GetName() const
virtual char*TObject::GetObjectInfo(Int_t px, Int_t py) const
static Bool_tTObject::GetObjectStat()
virtual Option_t*TObject::GetOption() const
TThread::EPriorityGetPriority() const
TThread::EStateGetState() const
static TThread*GetThread(Long_t id)
static TThread*GetThread(const char* name)
static Int_tGetTime(ULong_t* absSec, ULong_t* absNanoSec)
virtual const char*TNamed::GetTitle() const
virtual UInt_tTObject::GetUniqueID() const
virtual Bool_tTObject::HandleTimer(TTimer* timer)
virtual ULong_tTNamed::Hash() const
virtual voidTObject::Info(const char* method, const char* msgfmt) const
virtual Bool_tTObject::InheritsFrom(const char* classname) const
virtual Bool_tTObject::InheritsFrom(const TClass* cl) const
static voidInitialize()
virtual voidTObject::Inspect() constMENU
voidTObject::InvertBit(UInt_t f)
virtual TClass*IsA() const
virtual Bool_tTObject::IsEqual(const TObject* obj) const
virtual Bool_tTObject::IsFolder() const
static Bool_tIsInitialized()
Bool_tTObject::IsOnHeap() const
virtual Bool_tTNamed::IsSortable() const
Bool_tTObject::IsZombie() const
Long_tJoin(void** ret = 0)
static Long_tJoin(Long_t id, void** ret = 0)
Int_tKill()
static Int_tKill(Long_t id)
static Int_tKill(const char* name)
static Int_tLock()
virtual voidTNamed::ls(Option_t* option = "") const
voidTObject::MayNotUse(const char* method) const
virtual Bool_tTObject::Notify()
voidTObject::Obsolete(const char* method, const char* asOfVers, const char* removedFromVers) const
voidTObject::operator delete(void* ptr)
voidTObject::operator delete(void* ptr, void* vp)
voidTObject::operator delete[](void* ptr)
voidTObject::operator delete[](void* ptr, void* vp)
void*TObject::operator new(size_t sz)
void*TObject::operator new(size_t sz, void* vp)
void*TObject::operator new[](size_t sz)
void*TObject::operator new[](size_t sz, void* vp)
virtual voidTObject::Paint(Option_t* option = "")
virtual voidTObject::Pop()
virtual voidTNamed::Print(Option_t* option = "") const
static voidPrintf(const char* fmt)
static voidPs()
static voidps()
virtual Int_tTObject::Read(const char* name)
virtual voidTObject::RecursiveRemove(TObject* obj)
voidTObject::ResetBit(UInt_t f)
Int_tRun(void* arg = 0)
virtual voidTObject::SaveAs(const char* filename = "", Option_t* option = "") constMENU
virtual voidTObject::SavePrimitive(ostream& out, Option_t* option = "")
static TThread*Self()
static Long_tSelfId()
voidTObject::SetBit(UInt_t f)
voidTObject::SetBit(UInt_t f, Bool_t set)
static Int_tSetCancelAsynchronous()
static Int_tSetCancelDeferred()
static Int_tSetCancelOff()
static Int_tSetCancelOn()
virtual voidTObject::SetDrawOption(Option_t* option = "")MENU
static voidTObject::SetDtorOnly(void* obj)
virtual voidTNamed::SetName(const char* name)MENU
virtual voidTNamed::SetNameTitle(const char* name, const char* title)
static voidTObject::SetObjectStat(Bool_t stat)
voidSetPriority(TThread::EPriority pri)
virtual voidTNamed::SetTitle(const char* title = "")MENU
virtual voidTObject::SetUniqueID(UInt_t uid)
virtual voidShowMembers(TMemberInspector& insp) const
virtual Int_tTNamed::Sizeof() const
static Int_tSleep(ULong_t secs, ULong_t nanos = 0)
virtual voidStreamer(TBuffer&)
voidStreamerNVirtual(TBuffer& ClassDef_StreamerNVirtual_b)
virtual voidTObject::SysError(const char* method, const char* msgfmt) const
Bool_tTObject::TestBit(UInt_t f) const
Int_tTObject::TestBits(UInt_t f) const
static Int_tTryLock()
static void**Tsd(void* dflt, Int_t k)
TThread(Long_t id = 0)
TThread(TThread::VoidRtnFunc_t fn, void* arg = 0, TThread::EPriority pri = kNormalPriority)
TThread(TThread::VoidFunc_t fn, void* arg = 0, TThread::EPriority pri = kNormalPriority)
TThread(const char* thname, TThread::VoidRtnFunc_t fn, void* arg = 0, TThread::EPriority pri = kNormalPriority)
TThread(const char* thname, TThread::VoidFunc_t fn, void* arg = 0, TThread::EPriority pri = kNormalPriority)
static Int_tUnLock()
virtual voidTObject::UseCurrentStyle()
virtual voidTObject::Warning(const char* method, const char* msgfmt) const
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0)
virtual Int_tTObject::Write(const char* name = 0, Int_t option = 0, Int_t bufsize = 0) const
static voidXAction()
protected:
voidTObject::MakeZombie()
private:
static voidAfterCancel(TThread* th)
voidConstructor()
virtual voidDoError(Int_t level, const char* location, const char* fmt, va_list va) const
voidErrorHandler(int level, const char* location, const char* fmt, va_list ap) const
static void*Function(void* ptr)
static voidInit()
TThread&operator=(const TThread&)
voidSetComment(const char* txt = 0)
TThread(const TThread&)
static Int_tXARequest(const char* xact, Int_t nb, void** ar, Int_t* iret)

Data Members

public:
static TObject::<anonymous>TObject::kBitMask
static TObject::EStatusBitsTObject::kCanDelete
static TThread::EStatekCanceledState
static TThread::EStatekCancelingState
static TObject::EStatusBitsTObject::kCannotPick
static TThread::EStatekDeletingState
static TThread::EStatekFinishedState
static TObject::EStatusBitsTObject::kHasUUID
static TThread::EPrioritykHighPriority
static TObject::EStatusBitsTObject::kInvalidObject
static TThread::EStatekInvalidState
static TObject::<anonymous>TObject::kIsOnHeap
static TObject::EStatusBitsTObject::kIsReferenced
static TThread::EPrioritykLowPriority
static TObject::EStatusBitsTObject::kMustCleanup
static TThread::EStatekNewState
static TObject::EStatusBitsTObject::kNoContextMenu
static TThread::EPrioritykNormalPriority
static TObject::<anonymous>TObject::kNotDeleted
static TObject::EStatusBitsTObject::kObjInCanvas
static TObject::<anonymous>TObject::kOverwrite
static TThread::EStatekRunningState
static TObject::<anonymous>TObject::kSingleKey
static TThread::EStatekTerminatedState
static TObject::<anonymous>TObject::kWriteDelete
static TObject::<anonymous>TObject::kZombie
protected:
TStringTNamed::fNameobject identifier
TStringTNamed::fTitleobject title
private:
void*fCleansupport of cleanup structure
charfComment[100]thread specific state comment
Bool_tfDetachedkTRUE if thread is Detached
TThread::VoidRtnFunc_tfFcnRetnvoid* start function of thread
TThread::VoidFunc_tfFcnVoidvoid start function of thread
Long_tfHandleWin32 thread handle
TThread**fHolderpointer to holder of this (delete only)
Long_tfIdthread id
Bool_tfNamedkTRUE if thread is Named
TThread*fNextpointer to next thread
TThread*fPrevpointer to prev thread
TThread::EPriorityfPrioritythread priority
TThread::EStatefStatethread state
TThread::EStatefStateComingcoming thread state
void*fThreadArgthread start function arguments
void*fTsd[24]thread specific data container
static TThread*fgMainpointer to chain of TThread's
static Long_tfgMainIdthread id of main thread
static TMutex*fgMainMutexmutex to protect chain of threads
static TThreadImp*fgThreadImpstatic pointer to thread implementation
static char*volatilefgXActAction name to do by main thread
static TCondition*fgXActCondicondition for XAction
static TMutex*fgXActMutexmutex to protect XAction
static volatile Int_tfgXAnbsize of array above
static void**volatilefgXArrpointer to control array of void pointers for action
static volatile Int_tfgXArtreturn XA flag

Class Charts

Inheritance Inherited Members Includes Libraries
Class Charts

Function documentation

TThread(VoidRtnFunc_t fn, void *arg, EPriority pri)
 Create a thread. Specify the function or static class method
 to be executed by the thread and a pointer to the argument structure.
 The user function should return a void*. To start the thread call Run().
TThread(VoidFunc_t fn, void *arg, EPriority pri)
 Create a detached thread. Specify the function or static class method
 to be executed by the thread and a pointer to the argument structure.
 To start the thread call Run().
TThread(const char *thname, VoidRtnFunc_t fn, void *arg, EPriority pri)
 Create thread with a name. Specify the function or static class method
 to be executed by the thread and a pointer to the argument structure.
 The user function should return a void*. To start the thread call Run().
TThread(const char *thname, VoidFunc_t fn, void *arg, EPriority pri)
 Create a detached thread with a name. Specify the function or static
 class method to be executed by the thread and a pointer to the argument
 structure. To start the thread call Run().
TThread(Long_t id = 0)
 Create a TThread for a already running thread.
void Initialize()
 Initialize the Thread package. This initializes the TThread and ROOT
 global mutexes to make parts of ROOT thread safe/aware. This call is
 implicit in case a TThread is created.
Bool_t IsInitialized()
 Return true, if the TThread objects have been initialize. If false,
 the process is (from ROOT's point of view) single threaded.
void Init()
 Initialize global state and variables once.
void Constructor()
 Common thread constructor.
~TThread()
 Cleanup the thread.
Int_t Delete(TThread*& th)
 Static method to delete the specified thread.
 Returns -1 in case the thread was running and has been killed. Returns
 0 in case the thread has been Delete and Cleaned up. The th pointer is
 not valid anymore in that case.
Int_t Exists()
 Static method to check if threads exist.
 Returns the number of running threads.
void SetPriority(TThread::EPriority pri)
 Set thread priority.
TThread * GetThread(Long_t id)
 Static method to find a thread by id.
TThread * GetThread(const char* name)
 Static method to find a thread by name.
TThread * Self()
 Static method returning pointer to current thread.
Long_t Join(void** ret = 0)
 Join this thread.
Long_t Join(Long_t id, void** ret = 0)
 Static method to join a thread by id.
Long_t SelfId()
 Static method returning the id for the current thread.
Int_t Run(void* arg = 0)
 Start the thread. This starts the static method TThread::Function()
 which calls the user function specified in the TThread ctor with
 the arg argument. Returns 0 on success, otherwise an error number will
 be returned.
Int_t Kill()
 Kill this thread. Returns 0 on success, otherwise an error number will
 be returned.
Int_t Kill(Long_t id)
 Static method to kill the thread by id. Returns 0 on success, otherwise
 an error number will be returned.
Int_t Kill(const char* name)
 Static method to kill thread by name. Returns 0 on success, otherwise
 an error number will be returned.
Int_t SetCancelOff()
 Static method to turn off thread cancellation. Returns 0 on success,
 otherwise an error number will be returned.
Int_t SetCancelOn()
 Static method to turn on thread cancellation. Returns 0 on success,
 otherwise an error number will be returned.
Int_t SetCancelAsynchronous()
 Static method to set the cancellation response type of the calling thread
 to asynchronous, i.e. cancel as soon as the cancellation request
 is received.
Int_t SetCancelDeferred()
 Static method to set the cancellation response type of the calling thread
 to deferred, i.e. cancel only at next cancellation point.
 Returns 0 on success, otherwise an error number will be returned.
Int_t CancelPoint()
 Static method to set a cancellation point. Returns 0 on success, otherwise
 an error number will be returned.
Int_t CleanUpPush(void* free, void* arg = 0)
 Static method which pushes thread cleanup method on stack.
 Returns 0 in case of success and -1 in case of error.
Int_t CleanUpPop(Int_t exe = 0)
 Static method which pops thread cleanup method off stack.
 Returns 0 in case of success and -1 in case of error.
Int_t CleanUp()
 Static method to cleanup the calling thread.
void AfterCancel(TThread* th)
 Static method which is called after the thread has been canceled.
Int_t Exit(void* ret = 0)
 Static method which terminates the execution of the calling thread.
Int_t Sleep(ULong_t secs, ULong_t nanos = 0)
 Static method to sleep the calling thread.
Int_t GetTime(ULong_t* absSec, ULong_t* absNanoSec)
 Static method to get the current time. Returns
 the number of seconds.
Int_t Lock()
 Static method to lock the main thread mutex.
Int_t TryLock()
 Static method to try to lock the main thread mutex.
Int_t UnLock()
 Static method to unlock the main thread mutex.
void * Function(void* ptr)
 Static method which is called by the system thread function and
 which in turn calls the actual user function.
void Ps()
 Static method listing the existing threads.
void ** Tsd(void* dflt, Int_t k)
 Static method returning a pointer to thread specific data container
 of the calling thread.
 k should be between 0 and kMaxUserThreadSlot for user application.
 (and between kMaxUserThreadSlot and kMaxThreadSlot for ROOT libraries).
 See ROOT::EThreadSlotReservation
void Printf(const char *va_(fmt), ...)
 Static method providing a thread safe printf. Appends a newline.
void ErrorHandler(int level, const char* location, const char* fmt, va_list ap) const
 Thread specific error handler function.
 It calls the user set error handler in the main thread.
void DoError(Int_t level, const char* location, const char* fmt, va_list va) const
 Interface to ErrorHandler. User has to specify the class name as
 part of the location, just like for the global Info(), Warning() and
 Error() functions.
Int_t XARequest(const char* xact, Int_t nb, void** ar, Int_t* iret)
 Static method used to allow commands to be executed by the main thread.
void XAction()
 Static method called via the thread timer to execute in the main
 thread certain commands. This to avoid sophisticated locking and
 possible deadlocking.
void SetComment(const char* txt = 0)
TThread(const TThread& )
TThread& operator=(const TThread& )
void Delete(Option_t* option = "")
{ TObject::Delete(option); }
EPriority GetPriority() const
{ return fPriority; }
EState GetState() const
{ return fState; }
Long_t GetId() const
{ return fId; }
void ps()
{ Ps(); }