/usr/include/root/TThread.h is in libroot-core-dev 5.34.19+dfsg-1.2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 | // @(#)root/thread:$Id$
// Author: Fons Rademakers 02/07/97
/*************************************************************************
* Copyright (C) 1995-2000, Rene Brun and Fons Rademakers. *
* All rights reserved. *
* *
* For the licensing terms see $ROOTSYS/LICENSE. *
* For the list of contributors see $ROOTSYS/README/CREDITS. *
*************************************************************************/
#ifndef ROOT_TThread
#define ROOT_TThread
//////////////////////////////////////////////////////////////////////////
// //
// 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). //
// //
//////////////////////////////////////////////////////////////////////////
#ifndef ROOT_TObject
#include "TObject.h"
#endif
#ifndef ROOT_TMutex
#include "TMutex.h"
#endif
#ifndef ROOT_TCondition
#include "TCondition.h"
#endif
#ifndef ROOT_TSystem
#include "TSystem.h"
#endif
#ifndef ROOT_TTimer
#include "TTimer.h"
#endif
#ifndef ROOT_Varargs
#include "Varargs.h"
#endif
#ifndef ROOT_TThreadSlots
#include "TThreadSlots.h"
#endif
class TThreadImp;
class TThread : public TNamed {
friend class TThreadImp;
friend class TPosixThread;
friend class TThreadTimer;
friend class TThreadCleaner;
friend class TWin32Thread;
public:
typedef void *(*VoidRtnFunc_t)(void *);
typedef void (*VoidFunc_t)(void *);
enum EPriority {
kLowPriority,
kNormalPriority,
kHighPriority
};
enum EState {
kInvalidState, // thread was not created properly
kNewState, // thread object exists but hasn't started
kRunningState, // thread is running
kTerminatedState, // thread has terminated but storage has not
// yet been reclaimed (i.e. waiting to be joined)
kFinishedState, // thread has finished
kCancelingState, // thread in process of canceling
kCanceledState, // thread has been canceled
kDeletingState // thread in process of deleting
};
private:
TThread *fNext; // pointer to next thread
TThread *fPrev; // pointer to prev thread
TThread **fHolder; // pointer to holder of this (delete only)
EPriority fPriority; // thread priority
EState fState; // thread state
EState fStateComing; // coming thread state
Long_t fId; // thread id
Long_t fHandle; // Win32 thread handle
Bool_t fDetached; // kTRUE if thread is Detached
Bool_t fNamed; // kTRUE if thread is Named
VoidRtnFunc_t fFcnRetn; // void* start function of thread
VoidFunc_t fFcnVoid; // void start function of thread
void *fThreadArg; // thread start function arguments
void *fClean; // support of cleanup structure
void *fTsd[ROOT::kMaxThreadSlot]; // thread specific data container
char fComment[100]; // thread specific state comment
static TThreadImp *fgThreadImp; // static pointer to thread implementation
static char * volatile fgXAct; // Action name to do by main thread
static void ** volatile fgXArr; // pointer to control array of void pointers for action
static volatile Int_t fgXAnb; // size of array above
static volatile Int_t fgXArt; // return XA flag
static Long_t fgMainId; // thread id of main thread
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
// Private Member functions
void Constructor();
void SetComment(const char *txt = 0)
{ fComment[0] = 0; if (txt) { strncpy(fComment, txt, 99); fComment[99] = 0; } }
void DoError(Int_t level, const char *location, const char *fmt, va_list va) const;
void ErrorHandler(int level, const char *location, const char *fmt, va_list ap) const;
static void Init();
static void *Function(void *ptr);
static Int_t XARequest(const char *xact, Int_t nb, void **ar, Int_t *iret);
static void AfterCancel(TThread *th);
TThread(const TThread&); // not implemented
TThread& operator=(const TThread&); // not implemented
public:
TThread(VoidRtnFunc_t fn, void *arg = 0, EPriority pri = kNormalPriority);
TThread(VoidFunc_t fn, void *arg = 0, EPriority pri = kNormalPriority);
TThread(const char *thname, VoidRtnFunc_t fn, void *arg = 0, EPriority pri = kNormalPriority);
TThread(const char *thname, VoidFunc_t fn, void *arg = 0, EPriority pri = kNormalPriority);
TThread(Long_t id = 0);
virtual ~TThread();
Int_t Kill();
Int_t Run(void *arg = 0);
void SetPriority(EPriority pri);
void Delete(Option_t *option="") { TObject::Delete(option); }
EPriority GetPriority() const { return fPriority; }
EState GetState() const { return fState; }
Long_t GetId() const { return fId; }
static void Ps();
static void ps() { Ps(); }
static void Initialize();
static Bool_t IsInitialized();
Long_t Join(void **ret = 0);
static Long_t Join(Long_t id, void **ret = 0);
static Int_t Exit(void *ret = 0);
static Int_t Exists();
static TThread *GetThread(Long_t id);
static TThread *GetThread(const char *name);
static Int_t Lock(); //User's lock of main mutex
static Int_t TryLock(); //User's try lock of main mutex
static Int_t UnLock(); //User's unlock of main mutex
static TThread *Self();
static Long_t SelfId();
static Int_t Sleep(ULong_t secs, ULong_t nanos = 0);
static Int_t GetTime(ULong_t *absSec, ULong_t *absNanoSec);
static Int_t Delete(TThread *&th);
static void **Tsd(void *dflt, Int_t k);
// Cancellation
// there are two types of TThread cancellation:
// DEFERRED - Cancellation only in user provided cancel-points
// ASYNCHRONOUS - In any point
// DEFERRED is more safe, it is DEFAULT.
static Int_t SetCancelOn();
static Int_t SetCancelOff();
static Int_t SetCancelAsynchronous();
static Int_t SetCancelDeferred();
static Int_t CancelPoint();
static Int_t Kill(Long_t id);
static Int_t Kill(const char *name);
static Int_t CleanUpPush(void *free, void *arg = 0);
static Int_t CleanUpPop(Int_t exe = 0);
static Int_t CleanUp();
// XActions
static void Printf(const char *fmt, ...) // format and print
#if defined(__GNUC__) && !defined(__CINT__)
__attribute__((format(printf, 1, 2)))
#endif
;
static void XAction();
ClassDef(TThread,0) // Thread class
};
//////////////////////////////////////////////////////////////////////////
// //
// TThreadCleaner //
// //
//////////////////////////////////////////////////////////////////////////
class TThreadCleaner {
public:
TThreadCleaner() { }
~TThreadCleaner();
};
//////////////////////////////////////////////////////////////////////////
// //
// TThreadTimer //
// //
//////////////////////////////////////////////////////////////////////////
class TThreadTimer : public TTimer {
public:
TThreadTimer(Long_t ms = 10);
Bool_t Notify();
};
#endif
|