GSI Object Oriented Online Offline (Go4)
GO4-6.3.0
|
#include <TGo4Thread.h>
Public Member Functions | |
TGo4Thread ()=delete | |
TGo4Thread (const TGo4Thread &right) | |
TGo4Thread (const char *name, TGo4Runnable *runnable, Bool_t internal=kTRUE) | |
virtual | ~TGo4Thread () |
Bool_t | Create () |
Bool_t | Cancel () |
Bool_t | ReCreate () |
Bool_t | Start () |
Bool_t | Stop () |
Int_t | GetPID () const |
Long_t | GetSelfID () const |
Bool_t | IsInternal () const |
Bool_t | IsCreated () const |
Bool_t | IsRunning () const |
Bool_t | IsWaiting () const |
Static Public Member Functions | |
static void | Sleep (UInt_t millisecs) |
Private Member Functions | |
TGo4Runnable * | GetRunnable () const |
TCondition * | GetCondition () const |
void | SetPID () |
void | SetSelfID () |
void | SetWaiting (Bool_t mode=kTRUE) |
Static Private Member Functions | |
static void | Threadfunc (void *arg) |
Private Attributes | |
Bool_t | fbIsInternal {kFALSE} |
Bool_t | fbIsCreated {kFALSE} |
Bool_t | fbIsRunning {kFALSE} |
Int_t | fiThreadPID {0} |
Long_t | fiThreadSelfID {0} |
Bool_t | fbIsWaiting {kFALSE} |
TGo4Runnable * | fxRunnable {nullptr} |
TThread * | fxThread {nullptr} |
TCondition * | fxCondition {nullptr} |
Class that encapsulates a root TThread which calls a user runnable Method (TGo4Runnable::Run()) in a loop. This working loop can be suspended to a condition wait to stop the action.
Definition at line 32 of file TGo4Thread.h.
|
delete |
TGo4Thread::TGo4Thread | ( | const TGo4Thread & | right | ) |
Definition at line 24 of file TGo4Thread.cxx.
References fbIsInternal, fxCondition, fxRunnable, and GO4TRACE.
TGo4Thread::TGo4Thread | ( | const char * | name, |
TGo4Runnable * | runnable, | ||
Bool_t | internal = kTRUE |
||
) |
TGo4Thread constructor parameters: name: name of the thread runnable: external user runnable to be executed from TThread. internal: define if thread shall be owned by threadmanager, or if it belongs to other aggregation
Definition at line 33 of file TGo4Thread.cxx.
References TGo4Log::Debug(), fbIsInternal, fxCondition, fxRunnable, GO4TRACE, and TGo4Runnable::SetThread().
|
virtual |
Definition at line 52 of file TGo4Thread.cxx.
References Cancel(), TGo4Log::Debug(), fbIsInternal, fxCondition, fxRunnable, GO4TRACE, and Stop().
Bool_t TGo4Thread::Cancel | ( | ) |
Cancels TThread
Definition at line 183 of file TGo4Thread.cxx.
References TGo4Log::Debug(), fbIsCreated, fbIsRunning, fiThreadPID, fiThreadSelfID, fxCondition, fxThread, GO4TRACE, and Sleep().
Referenced by TGo4ThreadHandler::Cancel(), TGo4ThreadHandler::CancelAll(), TGo4CancelException::Handle(), TGo4TestRunnable::Run(), and ~TGo4Thread().
Bool_t TGo4Thread::Create | ( | ) |
creates the TThread if not yet existing
Definition at line 168 of file TGo4Thread.cxx.
References fbIsCreated, fxThread, GO4TRACE, and Threadfunc().
Referenced by TGo4ThreadHandler::Create(), TGo4ThreadHandler::CreateAll(), TGo4CreateException::Handle(), ReCreate(), and Start().
|
inlineprivate |
Definition at line 101 of file TGo4Thread.h.
References fxCondition, SetPID(), and SetSelfID().
Referenced by Threadfunc().
|
inline |
linux process id associated with the pthread
Definition at line 72 of file TGo4Thread.h.
References fiThreadPID.
Referenced by TGo4ThreadHandler::AllCreated(), TGo4ThreadHandler::DumpThreads(), TGo4Runnable::ThreadCatch(), Threadfunc(), and TGo4Runnable::UnexpectedCatch().
|
inlineprivate |
We need this to have access to instance runnable from static Threadfunc:
Definition at line 99 of file TGo4Thread.h.
References fxRunnable.
Referenced by Threadfunc().
|
inline |
self id of the current thread
Definition at line 75 of file TGo4Thread.h.
References fiThreadSelfID.
Referenced by TGo4ThreadHandler::DumpThreads(), and Threadfunc().
|
inline |
kTRUE if TThread instance exists and pthread is created
Definition at line 82 of file TGo4Thread.h.
References fbIsCreated.
Referenced by Threadfunc().
|
inline |
returns flag indicating if go4thread object is internal to threadhandler or created externally
Definition at line 79 of file TGo4Thread.h.
References fbIsInternal.
Referenced by TGo4ThreadHandler::RemoveThread(), and TGo4ThreadHandler::~TGo4ThreadHandler().
|
inline |
Flag that controls Workfunc loop within Threadfunc
Definition at line 85 of file TGo4Thread.h.
References fbIsRunning.
Referenced by TGo4ThreadHandler::AllRunning(), and Threadfunc().
|
inline |
true if Threadfunc is suspended to condition wait
Definition at line 88 of file TGo4Thread.h.
References fbIsWaiting, and Threadfunc().
Referenced by TGo4ThreadHandler::AllWaiting(), TGo4ServerTask::ConnectorThreadIsStopped(), and TGo4TaskHandler::WaitThreadStop().
Bool_t TGo4Thread::ReCreate | ( | ) |
Stops old Runnable; Creates new TThread of same Runnable and name; cancels old Thread
Definition at line 215 of file TGo4Thread.cxx.
References Create(), TGo4Log::Debug(), fbIsCreated, fbIsWaiting, fiThreadPID, fiThreadSelfID, fxCondition, fxThread, GO4TRACE, Start(), Stop(), and Threadfunc().
Referenced by TGo4RestartException::Handle(), TGo4ThreadHandler::ReCreate(), and TGo4ThreadHandler::ReCreateAll().
|
private |
Definition at line 307 of file TGo4Thread.cxx.
References fiThreadPID.
Referenced by GetCondition(), and Threadfunc().
|
private |
Definition at line 302 of file TGo4Thread.cxx.
References fiThreadSelfID.
Referenced by GetCondition(), and Threadfunc().
|
inlineprivate |
|
static |
wrapper for gSystem->Sleep with consecutive TThread::CancelPoint - necessary for proper pthread termination
Definition at line 295 of file TGo4Thread.cxx.
References GO4TRACE.
Referenced by Cancel(), TGo4TaskHandlerRunnable::CheckTransportOpen(), TGo4HistogramServer::ConnectObjectClient(), TGo4ComInitAnalysis::ExeCom(), TGo4LoggingRunnable::Run(), TGo4WatchRunnable::Run(), TGo4ControllerRunnable::Run(), TGo4MainRunnable::Run(), TGo4AnalysisWatchRunnable::Run(), TGo4AnalysisMainRunnable::Run(), TGo4TestRunnable::Run(), TGo4TaskManager::ServeClient(), TGo4ServerTask::Shutdown(), Threadfunc(), TGo4TaskManager::WaitForClientRemoved(), TGo4HistogramServer::WaitForClose(), TGo4ServerTask::WaitForClose(), TGo4HistogramServer::WaitForConnection(), TGo4ServerTask::WaitForConnection(), TGo4HistogramServer::WaitForOpen(), TGo4ServerTask::WaitForOpen(), TGo4TaskHandler::WaitGetPort(), and TGo4TaskHandler::WaitThreadStop().
Bool_t TGo4Thread::Start | ( | ) |
starts runnable method Run within thread loop by setting running flag and signaling condition
Definition at line 269 of file TGo4Thread.cxx.
References Create(), fbIsCreated, fbIsRunning, fxCondition, and GO4TRACE.
Referenced by TGo4StartException::Handle(), ReCreate(), TGo4ThreadHandler::Start(), and TGo4ThreadHandler::StartAll().
Bool_t TGo4Thread::Stop | ( | ) |
resets running flag for runnable
Definition at line 287 of file TGo4Thread.cxx.
References fbIsRunning, and GO4TRACE.
Referenced by TGo4TaskHandlerRunnable::CheckStopBuffer(), TGo4TaskHandlerAbortException::Handle(), ReCreate(), TGo4ObjConnectorRunnable::Run(), TGo4AnalysisMainRunnable::Run(), TGo4StatusRunnable::Run(), TGo4DataRunnable::Run(), TGo4CommandRunnable::Run(), TGo4LocalCommandRunnable::Run(), TGo4ConnectorRunnable::Run(), TGo4ThreadHandler::Stop(), TGo4ThreadHandler::StopAll(), and ~TGo4Thread().
|
staticprivate |
This function is passed to TThread ctor and runs as pthread. Contains a loop that is controlled by Go4Thread own TCondition and by "function shall run" flag. Within the loop the virtual working function is called.
Definition at line 75 of file TGo4Thread.cxx.
References TGo4Log::Debug(), GetCondition(), GetPID(), GetRunnable(), GetSelfID(), GO4TRACE, IsCreated(), IsRunning(), TGo4Runnable::PostRun(), TGo4Runnable::PreRun(), TGo4Runnable::Run(), SetPID(), SetSelfID(), SetWaiting(), Sleep(), and TGo4Runnable::ThreadCatch().
Referenced by Create(), IsWaiting(), and ReCreate().
|
private |
kTRUE if TThread instance exists and pthread is created
Definition at line 117 of file TGo4Thread.h.
Referenced by Cancel(), Create(), IsCreated(), ReCreate(), and Start().
|
private |
specifies whether thread is internal thread of handler (true) or is owned by external class (false). In the latter case, thread instance and its runnable are not deleted when it is removed from the thread list
Definition at line 114 of file TGo4Thread.h.
Referenced by IsInternal(), TGo4Thread(), and ~TGo4Thread().
|
private |
Flag that controls Workfunc loop within Threadfunc
Definition at line 120 of file TGo4Thread.h.
Referenced by Cancel(), IsRunning(), Start(), and Stop().
|
private |
true if Threadfunc is suspended to condition wait
Definition at line 129 of file TGo4Thread.h.
Referenced by IsWaiting(), ReCreate(), and SetWaiting().
|
private |
Linux process id associated with the pthread
Definition at line 123 of file TGo4Thread.h.
Referenced by Cancel(), GetPID(), ReCreate(), and SetPID().
|
private |
self id of the current thread
Definition at line 126 of file TGo4Thread.h.
Referenced by Cancel(), GetSelfID(), ReCreate(), and SetSelfID().
|
private |
Definition at line 142 of file TGo4Thread.h.
Referenced by Cancel(), GetCondition(), ReCreate(), Start(), TGo4Thread(), and ~TGo4Thread().
|
private |
External class providing the threaded workfunction and exception routines for workfunction. The threaded action will be defined by creating a runnable subclass and overriding the TGo4Runnable::Run() method. Here exception handling behaviour may be overridden, too. 1 1
Definition at line 138 of file TGo4Thread.h.
Referenced by GetRunnable(), TGo4Thread(), and ~TGo4Thread().
|
private |
Definition at line 140 of file TGo4Thread.h.
Referenced by Cancel(), Create(), and ReCreate().