GRSISort
Created by P.C. Bender
Developement Team: P.C. Bender, R. Dunlop, V. Bildstein
An extension of the ROOT analysis Framework
StoppableThread Class Referenceabstract

Base-class for all loops/threads.

Definition at line 29 of file StoppableThread.h.

Public Member Functions

 StoppableThread (std::string name)
 
virtual ~StoppableThread ()
 
virtual void ClearQueue ()
 
virtual std::string EndStatus ()
 
virtual size_t GetItemsCurrent ()=0
 
virtual size_t GetItemsPopped ()=0
 
virtual size_t GetItemsPushed ()=0
 
virtual size_t GetRate ()=0
 
bool IsPaused ()
 
bool IsRunning ()
 
virtual bool Iteration ()=0
 
void Join ()
 
std::string Name () const
 
virtual void OnEnd ()
 
void Pause ()
 
virtual std::string Progress ()
 
void Resume ()
 
virtual std::string Status ()
 
void Stop ()
 

Static Public Member Functions

static std::string AllThreadHeader ()
 
static std::string AllThreadProgress ()
 
static std::string AllThreadStatus ()
 
static bool AnyThreadRunning ()
 
static std::string AnyThreadStatus ()
 
static void ClearAllQueues ()
 
static void ColumnWidth (size_t val)
 
static size_t ColumnWidth ()
 
static StoppableThreadGet (const std::string &name)
 
static std::vector< StoppableThread * > GetAll ()
 
static int GetNThreads ()
 
static void join_status_thread ()
 
static void PauseAll ()
 
static void Print ()
 
static void ResumeAll ()
 
static void SendStop ()
 
static void start_status_thread ()
 
static void status_out ()
 
static void status_out_loop ()
 
static void StatusWidth (size_t val)
 
static size_t StatusWidth ()
 
static void stop_status_thread ()
 
static void StopAll ()
 

Static Public Attributes

static std::thread fStatusThread
 
static bool fStatusThreadOn = false
 

Protected Attributes

std::atomic_long fInputSize {0}
 
std::atomic_size_t fItemsPopped {0}
 
std::string fName
 

Static Protected Attributes

static std::map< std::string, StoppableThread * > fThreadMap
 

Private Member Functions

 StoppableThread (const StoppableThread &)
 
 ClassDef (StoppableThread, 0)
 
void Loop ()
 
StoppableThreadoperator= (const StoppableThread &)
 

Private Attributes

std::atomic_bool fForceStop {false}
 
std::atomic_bool fPaused {false}
 
std::condition_variable fPausedWait
 
std::mutex fPauseMutex
 
std::atomic_bool fRunning {false}
 
std::thread fThread
 

Static Private Attributes

static size_t fColumnWidth = 20
 
static size_t fStatusWidth = 80
 

#include <StoppableThread.h>

+ Inheritance diagram for StoppableThread:
+ Collaboration diagram for StoppableThread:

Constructor & Destructor Documentation

◆ StoppableThread() [1/2]

StoppableThread::StoppableThread ( std::string  name)

Definition at line 26 of file StoppableThread.cxx.

References fName, fStatusThreadOn, fThread, fThreadMap, Loop(), and start_status_thread().

◆ ~StoppableThread()

StoppableThread::~StoppableThread ( )
virtual

Definition at line 182 of file StoppableThread.cxx.

References fName, fStatusThread, fStatusThreadOn, and fThreadMap.

◆ StoppableThread() [2/2]

StoppableThread::StoppableThread ( const StoppableThread )
inlineprivate

Definition at line 101 of file StoppableThread.h.

Member Function Documentation

◆ AllThreadHeader()

std::string StoppableThread::AllThreadHeader ( )
static

Definition at line 73 of file StoppableThread.cxx.

References fColumnWidth, fStatusWidth, and fThreadMap.

Referenced by TGRSIint::ApplyOptions().

◆ AllThreadProgress()

std::string StoppableThread::AllThreadProgress ( )
static

Definition at line 59 of file StoppableThread.cxx.

References fColumnWidth, fStatusWidth, and fThreadMap.

Referenced by TGRSIint::LoopUntilDone().

◆ AllThreadStatus()

std::string StoppableThread::AllThreadStatus ( )
static

Definition at line 83 of file StoppableThread.cxx.

References fColumnWidth, fStatusWidth, and fThreadMap.

Referenced by TGRSIint::LoopUntilDone().

◆ AnyThreadRunning()

bool StoppableThread::AnyThreadRunning ( )
static

◆ AnyThreadStatus()

std::string StoppableThread::AnyThreadStatus ( )
static

Definition at line 47 of file StoppableThread.cxx.

References fThreadMap.

◆ ClassDef()

StoppableThread::ClassDef ( StoppableThread  ,
 
)
private

◆ ClearAllQueues()

void StoppableThread::ClearAllQueues ( )
static

Definition at line 166 of file StoppableThread.cxx.

References fThreadMap.

Referenced by TGRSIInterruptHandler::Notify().

◆ ClearQueue()

virtual void StoppableThread::ClearQueue ( )
inlinevirtual

◆ ColumnWidth() [1/2]

static void StoppableThread::ColumnWidth ( size_t  val)
inlinestatic

Definition at line 75 of file StoppableThread.h.

References fColumnWidth.

◆ ColumnWidth() [2/2]

static size_t StoppableThread::ColumnWidth ( )
inlinestatic

Definition at line 77 of file StoppableThread.h.

References fColumnWidth.

Referenced by TGRSIint::SetupPipeline().

◆ EndStatus()

virtual std::string StoppableThread::EndStatus ( )
inlinevirtual

Reimplemented in TUnpackingLoop, TEventBuildingLoop, TFragWriteLoop, and TAnalysisWriteLoop.

Definition at line 57 of file StoppableThread.h.

Referenced by Join(), and Stop().

◆ Get()

◆ GetAll()

std::vector< StoppableThread * > StoppableThread::GetAll ( )
static

Definition at line 315 of file StoppableThread.cxx.

References fThreadMap.

◆ GetItemsCurrent()

◆ GetItemsPopped()

◆ GetItemsPushed()

◆ GetNThreads()

int StoppableThread::GetNThreads ( )
static

Definition at line 21 of file StoppableThread.cxx.

References fThreadMap.

Referenced by Print().

◆ GetRate()

◆ IsPaused()

bool StoppableThread::IsPaused ( )

Definition at line 224 of file StoppableThread.cxx.

References fPaused.

◆ IsRunning()

bool StoppableThread::IsRunning ( )

Definition at line 219 of file StoppableThread.cxx.

References fRunning.

Referenced by status_out().

◆ Iteration()

◆ Join()

void StoppableThread::Join ( )

Definition at line 229 of file StoppableThread.cxx.

References EndStatus(), and fThread.

Referenced by StopAll().

◆ join_status_thread()

void StoppableThread::join_status_thread ( )
static

Definition at line 280 of file StoppableThread.cxx.

References fStatusThread, and stop_status_thread().

◆ Loop()

void StoppableThread::Loop ( )
private

Definition at line 237 of file StoppableThread.cxx.

References fPaused, fPausedWait, fPauseMutex, fRunning, Iteration(), and OnEnd().

Referenced by StoppableThread().

◆ Name()

std::string StoppableThread::Name ( ) const
inline

◆ OnEnd()

virtual void StoppableThread::OnEnd ( )
inlinevirtual

Reimplemented in TAnalysisWriteLoopClient, TFragmentChainLoop, TAnalysisWriteLoop, and TDataLoop.

Definition at line 54 of file StoppableThread.h.

Referenced by Loop().

◆ operator=()

StoppableThread& StoppableThread::operator= ( const StoppableThread )
inlineprivate

Definition at line 102 of file StoppableThread.h.

◆ Pause()

void StoppableThread::Pause ( )

Definition at line 202 of file StoppableThread.cxx.

References fPaused, and fRunning.

◆ PauseAll()

void StoppableThread::PauseAll ( )
static

Definition at line 97 of file StoppableThread.cxx.

References fThreadMap.

◆ Print()

void StoppableThread::Print ( )
static

Definition at line 254 of file StoppableThread.cxx.

References fColumnWidth, fStatusWidth, fThreadMap, GetNThreads(), and hex().

◆ Progress()

std::string StoppableThread::Progress ( )
virtual

Definition at line 119 of file StoppableThread.cxx.

References fColumnWidth, fInputSize, and fItemsPopped.

◆ Resume()

void StoppableThread::Resume ( )

Definition at line 193 of file StoppableThread.cxx.

References fPaused, fPausedWait, fPauseMutex, and fRunning.

◆ ResumeAll()

void StoppableThread::ResumeAll ( )
static

Definition at line 104 of file StoppableThread.cxx.

References fThreadMap.

Referenced by TGRSIint::SetupPipeline().

◆ SendStop()

void StoppableThread::SendStop ( )
static

Definition at line 135 of file StoppableThread.cxx.

References fThreadMap, and Stop().

Referenced by StopAll(), and TGRSIint::Terminate().

◆ start_status_thread()

void StoppableThread::start_status_thread ( )
static

Definition at line 265 of file StoppableThread.cxx.

References fStatusThread, fStatusThreadOn, and status_out_loop().

Referenced by StoppableThread().

◆ Status()

std::string StoppableThread::Status ( )
virtual

Definition at line 111 of file StoppableThread.cxx.

References fColumnWidth, fInputSize, and fItemsPopped.

◆ status_out()

void StoppableThread::status_out ( )
static

◆ status_out_loop()

void StoppableThread::status_out_loop ( )
static

Definition at line 286 of file StoppableThread.cxx.

References fStatusThreadOn, and status_out().

Referenced by start_status_thread().

◆ StatusWidth() [1/2]

static void StoppableThread::StatusWidth ( size_t  val)
inlinestatic

Definition at line 76 of file StoppableThread.h.

References fStatusWidth.

◆ StatusWidth() [2/2]

static size_t StoppableThread::StatusWidth ( )
inlinestatic

Definition at line 78 of file StoppableThread.h.

References fStatusWidth.

Referenced by TGRSIint::SetupPipeline().

◆ Stop()

void StoppableThread::Stop ( )

Definition at line 209 of file StoppableThread.cxx.

References EndStatus(), fPaused, fPausedWait, fPauseMutex, and fRunning.

Referenced by SendStop().

◆ stop_status_thread()

void StoppableThread::stop_status_thread ( )
static

Definition at line 273 of file StoppableThread.cxx.

References fStatusThreadOn.

Referenced by join_status_thread().

◆ StopAll()

void StoppableThread::StopAll ( )
static

Definition at line 147 of file StoppableThread.cxx.

References fThreadMap, Join(), SendStop(), and status_out().

Referenced by TGRSIint::Terminate().

Member Data Documentation

◆ fColumnWidth

size_t StoppableThread::fColumnWidth = 20
staticprivate

◆ fForceStop

std::atomic_bool StoppableThread::fForceStop {false}
private

Definition at line 112 of file StoppableThread.h.

◆ fInputSize

◆ fItemsPopped

◆ fName

std::string StoppableThread::fName
protected

Definition at line 99 of file StoppableThread.h.

Referenced by Name(), StoppableThread(), and ~StoppableThread().

◆ fPaused

std::atomic_bool StoppableThread::fPaused {false}
private

Definition at line 113 of file StoppableThread.h.

Referenced by IsPaused(), Loop(), Pause(), Resume(), and Stop().

◆ fPausedWait

std::condition_variable StoppableThread::fPausedWait
private

Definition at line 114 of file StoppableThread.h.

Referenced by Loop(), Resume(), and Stop().

◆ fPauseMutex

std::mutex StoppableThread::fPauseMutex
private

Definition at line 115 of file StoppableThread.h.

Referenced by Loop(), Resume(), and Stop().

◆ fRunning

std::atomic_bool StoppableThread::fRunning {false}
private

Definition at line 111 of file StoppableThread.h.

Referenced by IsRunning(), Loop(), Pause(), Resume(), and Stop().

◆ fStatusThread

std::thread StoppableThread::fStatusThread
static

Definition at line 81 of file StoppableThread.h.

Referenced by join_status_thread(), start_status_thread(), and ~StoppableThread().

◆ fStatusThreadOn

bool StoppableThread::fStatusThreadOn = false
static

◆ fStatusWidth

size_t StoppableThread::fStatusWidth = 80
staticprivate

◆ fThread

std::thread StoppableThread::fThread
private

Definition at line 110 of file StoppableThread.h.

Referenced by Join(), and StoppableThread().

◆ fThreadMap