library: libThread #include "TThread.h"

# TThread

class description - source file - inheritance tree (.ps)

## class TThread : public TNamed

| Inheritance Chart:

`TObject`

<-

`TNamed`

<-

`TThread`

        private:

             static void AfterCancel(TThread* th)
          static ULong_t Call(void* p2f, void* arg)
                    void Constructor()
            static void* Fun(void* ptr)
             const char* GetComm() const
                    void PutComm(const char* txt = "0")
            static Int_t XARequest(const char* xact, Int_t nb, void** ar, Int_t* iret)

        public:

                             TThread(TThread::VoidRtnFunc_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(Int_t id = 0)
                             TThread(const TThread&)
                     virtual ~TThread()
                static Int_t CancelPoint()
              static TClass* Class()
                static Int_t CleanUp()
                static Int_t CleanUpPop(Int_t exe = 0)
                static Int_t CleanUpPush(void* free, void* arg = 0)
                 static void Debug(const char* txt)
                virtual void Delete(Option_t* option)
                static Int_t Delete(TThread*& th)
                static Int_t Exists()
                static Int_t Exit(void* ret = 0)
                      Long_t GetId() const
                      Long_t GetJoinId() const
          TThread::EPriority GetPriority() const
             TThread::EState GetState() const
             static TThread* GetThread(Long_t id)
             static TThread* GetThread(const char* name)
                static Int_t GetTime(ULong_t* absSec, ULong_t* absNanoSec)
             virtual TClass* IsA() const
               static Long_t Join(Long_t id, void** ret = 0)
               static Long_t Join(void** ret = 0)
                       Int_t Kill()
                static Int_t Kill(Long_t id)
                static Int_t Kill(const char* name)
                static Int_t Lock()
                static Int_t MakeFun(char* funname)
                    TThread& operator=(const TThread&)
                 static void Printf(const char* txt)
                 static void Printf(const char* txt, Long_t i)
                 static void Printf(const char* txt, void* i)
                        void Ps()
                        void ps()
                       Int_t Run(void* arg = 0)
             static TThread* Self()
               static Long_t SelfId()
                static Int_t SetCancelAsynchronous()
                static Int_t SetCancelDeferred()
                static Int_t SetCancelOff()
                static Int_t SetCancelOn()
                        void SetJoinId(TThread* tj)
                        void SetJoinId(Long_t jid)
                        void SetPriority(TThread::EPriority pri)
                virtual void ShowMembers(TMemberInspector& insp, char* parent)
                static Int_t Sleep(ULong_t secs, ULong_t nanos = 0)
                virtual void Streamer(TBuffer& b)
                        void StreamerNVirtual(TBuffer& b)
                static Int_t TryLock()
               static void** Tsd(void* dflt, Int_t k)
                static Int_t UnLock()
                 static void XAction()

### Data Members

        private:

                    TThread* fNext           pointer to next thread
                    TThread* fPrev           pointer to prev thread
                   TThread** fHolder         pointer to holder of this (delete only)
          TThread::EPriority fPriority       thread priority
             TThread::EState fState          thread state
             TThread::EState fStateComing    coming thread state
                      Long_t fId             thread id
                      Long_t fJoinId         thread id to whom can join
                      Bool_t fDetached       kTRUE if thread is Detached
                      Bool_t fNamed          kTRUE if thread is Named
                       void* fFcnRetn        void* start function of thread
                       void* fFcnVoid        void  start function of thread
                       void* fThreadArg      thread start function arguments
                       void* fClean          support of cleanup structure
                       void* fTsd[20]        thread specific data container
                        char fComm[100]      ????
          static TThreadImp* fgThreadImp     static pointer to thread implementation
                static char* fgXAct          Action name to do by main thread
               static void** volatilefgXArr  pointer to control array of void pointers for action
                static Int_t fgXAnb          size of array above
                static Int_t fgXArt          return XA flag
             static TThread* fgMain          pointer to chain of TThread's
              static TMutex* fgMainMutex     mutex to protect chain of threads
              static TMutex* fgXActMutex     mutex to protect XAction
          static TCondition* fgXActCondi     Condition for XAction

        public:

          static const TThread::EPriority kLowPriority
          static const TThread::EPriority kNormalPriority
          static const TThread::EPriority kHighPriority
             static const TThread::EState kInvalidState
             static const TThread::EState kNewState
             static const TThread::EState kRunningState
             static const TThread::EState kTerminatedState
             static const TThread::EState kFinishedState
             static const TThread::EState kCancelingState
             static const TThread::EState kCanceledState
             static const TThread::EState kDeletingState

## Class Description

     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, TThreadSolaris or TThreadNT).

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 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) : TNamed(thname, "")

     Create thread with a name. Specify the function or 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) : TNamed(thname, "")

     Create a detached thread with a name. Specify the function or class
     method to be executed by the thread and a pointer to the argument
     structure. To start the thread call Run().

TThread(Int_t id)

     Create a TThread for a already running thread.

void Constructor()

     Common thread constructor.

~TThread()

     Cleanup the thread.

Int_t Delete(TThread *&th)

void Debug(const char *txt)

Int_t Exists()

     Check existing threads
     return number of running Threads

void SetPriority(EPriority pri)

     Set thread priority.

void SetJoinId(Long_t jid)

     Set id of thread to join.

void SetJoinId(TThread *tj)

     Set thread to join.

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)

     Static method to join thread. (rdm?)

Long_t Join(Long_t jid, void **ret)

Long_t SelfId()

Int_t Run(void *arg)

Int_t Kill()

Int_t Kill(Long_t id)

Int_t Kill(const char *name)

Int_t SetCancelOff()

Int_t SetCancelOn()

Int_t SetCancelAsynchronous()

Int_t SetCancelDeferred()

Int_t CancelPoint()

Int_t CleanUpPush(void *free, void *arg)

Int_t CleanUpPop(Int_t exe)

Int_t CleanUp()

void AfterCancel(TThread *th)

Int_t Exit(void *ret)

Int_t Sleep(ULong_t secs, ULong_t nanos)

Int_t GetTime(ULong_t *absSec, ULong_t *absNanoSec)

Int_t Lock()

Int_t TryLock()

Int_t UnLock()

ULong_t Call(void *p2f, void *arg)

void* Fun(void *ptr)

void Ps()

     List existing threads.

void** Tsd(void *dflt,Int_t k)

void Printf(const char *txt)

void Printf(const char *txt, Long_t in)

Int_t XARequest(const char *xact, Int_t nb, void **ar, Int_t *iret)

void XAction()

Int_t MakeFun(char *funname)

### Inline Functions

                          void PutComm(const char* txt = "0")
                   const char* GetComm() const
            TThread::EPriority GetPriority() const
               TThread::EState GetState() const
                        Long_t GetId() const
                          void ps()
                        Long_t GetJoinId() const
                         Int_t Delete(TThread*& th)
                          void Printf(const char* txt, void* i)
                       TClass* Class()
                       TClass* IsA() const
                          void ShowMembers(TMemberInspector& insp, char* parent)
                          void Streamer(TBuffer& b)
                          void StreamerNVirtual(TBuffer& b)
                      TThread& operator=(const TThread&)

Author: Fons Rademakers 02/07/97
Last update: root/thread:$Name: $:$Id: TThread.cxx,v 1.21 2004/07/08 11:52:32 rdm Exp $
Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *