GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
StoppableThread Class Referenceabstract

Detailed Description

Base-class for all loops/threads.

Definition at line 29 of file StoppableThread.h.

Public Member Functions

 StoppableThread (const StoppableThread &)=delete
 
 StoppableThread (std::string name)
 
 StoppableThread (StoppableThread &&) noexcept=delete
 
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 ()
 
StoppableThreadoperator= (const StoppableThread &)=delete
 
StoppableThreadoperator= (StoppableThread &&) noexcept=delete
 
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 size_t ColumnWidth ()
 
static void ColumnWidth (size_t val)
 
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 size_t StatusWidth ()
 
static void StatusWidth (size_t val)
 
static void stop_status_thread ()
 
static void StopAll ()
 

Protected Member Functions

void IncrementItemsPopped ()
 
std::atomic_long & InputSize ()
 
void InputSize (int64_t val)
 
std::atomic_size_t & ItemsPopped ()
 
void ItemsPopped (size_t val)
 

Private Member Functions

void Loop ()
 

Private Attributes

std::atomic_bool fForceStop {false}
 
std::atomic_long fInputSize {0}
 
std::atomic_size_t fItemsPopped {0}
 
std::string fName
 
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 std::thread fStatusThread
 
static bool fStatusThreadOn = false
 
static size_t fStatusWidth = 80
 
static std::map< std::string, StoppableThread * > fThreadMap
 
+ Inheritance diagram for StoppableThread:
+ Collaboration diagram for StoppableThread:

Constructor & Destructor Documentation

◆ StoppableThread() [1/3]

StoppableThread::StoppableThread ( std::string name)
explicit

Definition at line 26 of file StoppableThread.cxx.

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

◆ StoppableThread() [2/3]

StoppableThread::StoppableThread ( const StoppableThread & )
delete

◆ StoppableThread() [3/3]

StoppableThread::StoppableThread ( StoppableThread && )
deletenoexcept

◆ ~StoppableThread()

StoppableThread::~StoppableThread ( )
virtual

Definition at line 182 of file StoppableThread.cxx.

References fName, fStatusThread, fStatusThreadOn, and fThreadMap.

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.

◆ 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 size_t StoppableThread::ColumnWidth ( )
inlinestatic

Definition at line 82 of file StoppableThread.h.

References fColumnWidth.

Referenced by TGRSIint::SetupPipeline().

◆ ColumnWidth() [2/2]

static void StoppableThread::ColumnWidth ( size_t val)
inlinestatic

Definition at line 80 of file StoppableThread.h.

References fColumnWidth.

◆ EndStatus()

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

Reimplemented in TAnalysisWriteLoop, TEventBuildingLoop, TFragWriteLoop, and TUnpackingLoop.

Definition at line 62 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()

virtual size_t StoppableThread::GetItemsCurrent ( )
pure virtual

◆ GetItemsPopped()

virtual size_t StoppableThread::GetItemsPopped ( )
pure virtual

◆ GetItemsPushed()

virtual size_t StoppableThread::GetItemsPushed ( )
pure virtual

◆ GetNThreads()

int StoppableThread::GetNThreads ( )
static

Definition at line 21 of file StoppableThread.cxx.

References fThreadMap.

Referenced by Print().

◆ GetRate()

virtual size_t StoppableThread::GetRate ( )
pure virtual

◆ IncrementItemsPopped()

◆ InputSize() [1/2]

◆ InputSize() [2/2]

void StoppableThread::InputSize ( int64_t val)
inlineprotected

Definition at line 94 of file StoppableThread.h.

References fInputSize.

◆ 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().

◆ ItemsPopped() [1/2]

◆ ItemsPopped() [2/2]

void StoppableThread::ItemsPopped ( size_t val)
inlineprotected

Definition at line 93 of file StoppableThread.h.

References fItemsPopped.

◆ Iteration()

virtual bool StoppableThread::Iteration ( )
pure virtual

◆ 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 TAnalysisWriteLoop, TDataLoop, and TFragmentChainLoop.

Definition at line 59 of file StoppableThread.h.

Referenced by Loop().

◆ operator=() [1/2]

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

◆ operator=() [2/2]

StoppableThread & StoppableThread::operator= ( StoppableThread && )
deletenoexcept

◆ 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.

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 size_t StoppableThread::StatusWidth ( )
inlinestatic

Definition at line 83 of file StoppableThread.h.

References fStatusWidth.

Referenced by TGRSIint::SetupPipeline().

◆ StatusWidth() [2/2]

static void StoppableThread::StatusWidth ( size_t val)
inlinestatic

Definition at line 81 of file StoppableThread.h.

References fStatusWidth.

◆ Stop()

void StoppableThread::Stop ( )

Definition at line 209 of file StoppableThread.cxx.

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

◆ 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 120 of file StoppableThread.h.

◆ fInputSize

std::atomic_long StoppableThread::fInputSize {0}
private

number of items in the input (queue), only updated within Iteration(), so not always fully up-to-date (signed to hold error from queue::pop)

Definition at line 102 of file StoppableThread.h.

Referenced by InputSize(), InputSize(), Progress(), and Status().

◆ fItemsPopped

std::atomic_size_t StoppableThread::fItemsPopped {0}
private

number of items popped from input queue

Definition at line 101 of file StoppableThread.h.

Referenced by IncrementItemsPopped(), ItemsPopped(), ItemsPopped(), Progress(), and Status().

◆ fName

std::string StoppableThread::fName
private

Definition at line 106 of file StoppableThread.h.

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

◆ fPaused

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

Definition at line 121 of file StoppableThread.h.

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

◆ fPausedWait

std::condition_variable StoppableThread::fPausedWait
private

Definition at line 122 of file StoppableThread.h.

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

◆ fPauseMutex

std::mutex StoppableThread::fPauseMutex
private

Definition at line 123 of file StoppableThread.h.

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

◆ fRunning

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

Definition at line 119 of file StoppableThread.h.

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

◆ fStatusThread

std::thread StoppableThread::fStatusThread
staticprivate

Definition at line 117 of file StoppableThread.h.

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

◆ fStatusThreadOn

bool StoppableThread::fStatusThreadOn = false
staticprivate

◆ fStatusWidth

size_t StoppableThread::fStatusWidth = 80
staticprivate

◆ fThread

std::thread StoppableThread::fThread
private

Definition at line 118 of file StoppableThread.h.

Referenced by StoppableThread(), and Join().

◆ fThreadMap