DABC (Data Acquisition Backbone Core)  2.9.9
Data Structures | Public Types | Public Member Functions | Static Public Member Functions | Protected Types | Protected Member Functions | Protected Attributes | Static Protected Attributes | Friends
dabc::Thread Class Reference

Represent thread functionality. More...

#include <dabc/Thread.h>

Inheritance diagram for dabc::Thread:
dabc::Object dabc::PosixThread dabc::Runnable dabc::SocketThread verbs::Thread

Data Structures

class  EventsQueue
 
class  ExecWorker
 
  • helper class to use methods, available in dabc::Worker in thread itself
More...
 
class  RecursionGuard
 
struct  TimeoutRec
 
struct  WorkerRec
 

Public Types

enum  EEvents {
  evntCheckTmoutWorker = 1 , evntCheckTmoutAddon , evntCleanupThrd , evntDoNothing ,
  evntStopThrd , evntLastThrd , evntUser = 10000
}
 
enum  EPriority { priorityHighest = 0 , priorityNormal = 1 , priorityLowest = -1 }
 

Public Member Functions

virtual const char * ClassName () const
 Returns class name of the object instance. More...
 
virtual bool CompatibleClass (const std::string &clname) const
 
bool Execute (Command cmd, double tmout=-1)
 
void FireDoNothingEvent ()
 
double GetStopTimeout () const
 
bool IsItself () const
 
virtual void * MainLoop ()
 
virtual void Print (int lvl=0)
 Print thread content on debug output. More...
 
void RunEventLoop (double tmout=1.)
 Runs thread event loop for specified time. More...
 
void SetPriority (int prio=0)
 
void SetStopTimeout (double timeout_sec)
 
bool SingleLoop (unsigned workerid=0, double tmout=-1)
 Processes single event from the thread queue. More...
 
bool Start (double timeout_sec=-1., bool real_thread=true)
 
bool Stop (double timeout_sec=10)
 
bool Sync (double timeout_sec=-1)
 
 Thread (Reference parent, const std::string &name, Command cmd=nullptr)
 
unsigned TotalNumberOfEvents ()
 Return total number of all events in the queues. More...
 
virtual ~Thread ()
 
- Public Member Functions inherited from dabc::Object
bool AddChild (Object *child, bool withmutex=true) throw ()
 Add object to list of child objects, thread safe More...
 
bool AddChildAt (Object *child, unsigned pos, bool withmutex=true)
 Add object to list of child objects at specified position. More...
 
virtual void BuildFieldsMap (RecordFieldsMap *cont)
 Fill fields map, which is relevant for the object Objects hierarchy produced from dabc::Manager. More...
 
virtual bool Find (ConfigIO &cfg)
 Method to locate object in xml file. More...
 
ObjectFindChild (const char *name) const
 returns pointer on child object with given name More...
 
Reference FindChildRef (const char *name, bool force=false) const throw ()
 returns reference on child object with given name More...
 
bool GetAllChildRef (ReferencesVector *vect) const
 
ObjectGetChild (unsigned n) const
 returns pointer on child object More...
 
Reference GetChildRef (unsigned n) const
 returns reference on child object More...
 
Reference GetFolder (const std::string &name, bool force=false) throw ()
 Return folder of specified name, no special symbols allowed. More...
 
const char * GetName () const
 Returns name of the object, thread safe More...
 
ObjectGetParent () const
 Returns pointer on parent object, thread safe More...
 
Reference GetParentRef () const
 
bool IsChildsHidden () const
 Return true if object wants to hide childs from hierarchy scan, thread safe More...
 
bool IsHidden () const
 Return true if object wants to be hidden from hierarchy scan, thread safe More...
 
bool IsLogging () const
 Return true if object selected for logging, thread safe More...
 
bool IsName (const char *str) const
 Checks if object name is same as provided string, thread safe More...
 
bool IsName (const char *str, int len) const
 Checks if object name is same as provided, thread safe More...
 
bool IsName (const std::string &str) const
 Checks if object name is same as provided string, thread safe More...
 
bool IsNameMatch (const std::string &mask) const
 Check if object name match to the mask. More...
 
bool IsOwner () const
 Returns true if object is owner of its children, thread safe More...
 
bool IsParent (Object *obj) const
 Checks if specified argument is in the list of object parents. More...
 
bool IsTopXmlLevel () const
 Return true if object should be searched in the top level of the xml file, thread safe More...
 
std::string ItemName (bool compact=true) const
 Produce string, which can be used as name argument in dabc::mgr.FindItem(name) call. More...
 
unsigned NumChilds () const
 returns number of child objects More...
 
 Object (const std::string &name, unsigned flags=flIsOwner)
 Resolve problem with child-parent mutex locking. More...
 
 Object (Reference parent, const std::string &name, unsigned flags=flIsOwner)
 
bool RemoveChild (Object *child, bool cleanup=true) throw ()
 Detach child from parent object If cleanup==true and parent is owner of child, child will be destroyed. More...
 
bool RemoveChildAt (unsigned n, bool cleanup=true) throw ()
 Detach child object from parent at specified position If cleanup==true and object is owner of child, child will be destroyed. More...
 
bool RemoveChilds (bool cleanup=true)
 Remove all childs. More...
 
void SetLogging (bool on=true)
 Sets logging flag, thread safe More...
 
virtual ~Object ()
 

Static Public Member Functions

static unsigned NumThreadInstances ()
 
- Static Public Member Functions inherited from dabc::Object
static void Destroy (Object *obj) throw ()
 User method for object destroyment. More...
 
static void InspectGarbageCollector ()
 \ brief Methods to inspect how many objects pointers are remained More...
 
static bool NameMatch (const std::string &name, const std::string &mask)
 Check if name matches to specified mask. More...
 
static bool NameMatchM (const std::string &name, const std::string &mask)
 Check if name matches to specified mask. More...
 
static unsigned NumInstances ()
 Static variable counts total number of objects instances. More...
 

Protected Types

enum  EHaltActions { actDestroy = 1 , actHalt = 2 }
 
enum  EThreadState {
  stCreated , stRunning , stStopped , stError ,
  stChanging
}
 
typedef std::vector< WorkerRec * > WorkersVector
 
- Protected Types inherited from dabc::Object
enum  EFlags {
  flStateMask = 0x000f , flIsOwner = 0x0010 , flCleanup = 0x0020 , flHasThread = 0x0040 ,
  flAutoDestroy = 0x0080 , flLogging = 0x0100 , flNoMutex = 0x0200 , flHidden = 0x0400 ,
  flChildsHidden = 0x0800 , flTopXmlLevel = 0x1000
}
 
- Protected Types inherited from dabc::PosixThread
typedef void *() StartRoutine(void *)
 

Protected Member Functions

virtual bool _DoDeleteItself ()
 This method is called at the moment when DecReference think that object can be destroyed and wants to return true. More...
 
virtual void _Fire (const EventId &arg, int nq)
 
bool _GetNextEvent (EventId &)
 
void _PushEvent (const EventId &arg, int nq)
 
unsigned _TotalNumberOfEvents ()
 
bool AddWorker (Reference ref, bool sync=true)
 Internal DABC method, Add worker to thread; reference-safe Reference safe means - it is safe to call it as long as reference on thread is exists We use here reference on the worker to ensure that it does not disappear meanwhile. More...
 
void ChangeRecursion (unsigned id, bool inc)
 Method which allows to control recursion of each worker. More...
 
double CheckTimeouts (bool forcerecheck=false)
 
int CheckWorkerCanBeHalted (unsigned id, unsigned request=0, Command cmd=nullptr)
 Internal DABC method, used to verify if worker can be halted now while recursion is over Request indicates that halt action is requested : actDestroy = 1 or actHalt = 2. More...
 
virtual int ExecuteThreadCommand (Command cmd)
 
void Fire (const EventId &arg, int nq)
 
bool HaltWorker (Worker *proc)
 Halt worker - stops any execution, break recursion. More...
 
void IncWorkerFiredEvents (Worker *work)
 
bool InvokeWorkerDestroy (Worker *work)
 Cleanup object asynchronously. More...
 
bool IsTemporaryThread () const
 Returns true is this is temporary thread for command execution. More...
 
unsigned NumWorkers ()
 Returns actual number of workers. More...
 
virtual void ObjectCleanup ()
 Cleanup thread that manager is allowed to delete it. More...
 
void ProcessEvent (const EventId &)
 
virtual void ProcessExtraThreadEvent (const EventId &)
 Method to process events which are not processed by Thread class itself Should be used in derived classes for their events processing. More...
 
void ProcessNoneEvent ()
 
int RunCommandInTheThread (Worker *caller, Worker *dest, Command cmd)
 
void RunExplicitLoop ()
 
virtual void RunnableCancelled ()
 
bool SetExplicitLoop (Worker *work)
 
MutexThreadMutex () const
 
virtual bool WaitEvent (EventId &, double tmout)
 
void WorkerAddonChanged (Worker *work, bool assign=true)
 Called when worker addon changed on the fly. More...
 
virtual void WorkersSetChanged ()
 Virtual method, called from thread context to inform that number of workers are changed. More...
 
- Protected Member Functions inherited from dabc::Object
virtual void _ChildsChanged ()
 Method called when new childs are add or old are removed. More...
 
bool _IsNormalState ()
 Same as IsNormalState() but without mutex lock - user should lock mutex himself. More...
 
virtual ObjectCreateInstance (const std::string &name)
 Method used to create new item to be placed as child of the object. More...
 
void DeleteThis ()
 Method should be used by the object to delete itself. More...
 
virtual bool DestroyByOwnThread ()
 Internal DABC method, used to activate object cleanup via object thread Returns: false - object cannot be cleanup by the thread, true - thread guarantees that DestroyCalledFromOwnThread() will be called from thread context. More...
 
bool DestroyCalledFromOwnThread ()
 Internal DABC method, should be called by thread which was requested to destroy object. More...
 
void FillFullName (std::string &fullname, Object *upto, bool exclude_top_parent=false) const
 Method used to produce full item name,. More...
 
bool GetFlag (unsigned fl) const
 Return value of selected flag, not thread safe
More...
 
bool IsNormalState ()
 Return true if object is in normal state. More...
 
unsigned NumReferences ()
 Return number of references on the object. More...
 
 Object (const ConstructorPair &pair, unsigned flags=flIsOwner)
 
virtual void ObjectDestroyed (Object *)
 Method called by the manager when registered dependent object is destroyed Should be used in user class to clear all references on the object to let destroy it. More...
 
MutexObjectMutex () const
 Returns mutex, used for protection of Object data members. More...
 
void SetAutoDestroy (bool on=true)
 Set autodestroy flag for the object Once enabled, object will be destroyed when last reference will be cleared. More...
 
void SetFlag (unsigned fl, bool on=true)
 Change value of selected flag, not thread safe
More...
 
void SetName (const char *name)
 Changes object name. More...
 
void SetNameDirect (const char *name)
 Changes object name disregard of existing references. More...
 
void SetOwner (bool on=true)
 Specifies if object will be owner of its new childs. More...
 
- Protected Member Functions inherited from dabc::PosixThread
void UseCurrentAsSelf ()
 
void Cancel ()
 Try to cancel thread execution. More...
 
bool GetAffinity (bool actual, char *buf, unsigned maxbuf)
 Provides thread affinity in form of "xxxooooo". More...
 
Thread_t Id () const
 
bool IsItself () const
 Returns true if called from thread context. More...
 
void Join ()
 Join thread - method waits until thread execution is completed. More...
 
void Kill (int sig=9)
 Kill thread with specified signal. More...
 
 PosixThread ()
 
bool SetAffinity (const char *aff)
 Sets affinity mask for the thread. More...
 
void SetPriority (int prio)
 Change thread priority. More...
 
void SetThreadName (const char *thrdname)
 Set thread name, which can be seen from htop. More...
 
void Start (Runnable *run)
 Start thread with provided runnable. More...
 
void Start (StartRoutine *func, void *args)
 Start thread with provided routine and call arguments. More...
 
virtual ~PosixThread ()
 
- Protected Member Functions inherited from dabc::Runnable
virtual ~Runnable ()
 

Protected Attributes

bool fCheckThrdCleanup
 indicates if thread should be checked for clean up More...
 
bool fDidDecRefCnt
 indicates if object cleanup was called - need in destructor More...
 
ExecWorkerfExec
 processor to execute commands in the thread More...
 
unsigned fExplicitLoop
 id of the worker, selected to run own explicit loop More...
 
TimeStamp fLastProfileTime
 when doing profiling, last time when profiling was done More...
 
TimeStamp fNextTimeout
 indicate when we expects next timeout More...
 
int fNumQueues
 number of queues More...
 
int fProcessingTimeouts
 indicate recursion in timeouts processing More...
 
bool fProfiling
 if true, different statistic will be accumulated about thread More...
 
EventsQueuefQueues
 queues for threads events More...
 
bool fRealThrd
 indicate if we create real thread and not running mainloop from top process More...
 
EThreadState fState
 actual thread state More...
 
double fThrdStopTimeout
 time in second set as timeout when stopping thred More...
 
bool fThrdWorking
 flag indicates if mainloop of the thread should continue to work More...
 
double fThreadRunTime
 total run time (user and sys), measured by getrusage More...
 
Condition fWorkCond
 condition, which is used in default MainLoop implementation More...
 
WorkersVector fWorkers
 vector of all processors More...
 
- Protected Attributes inherited from dabc::Object
int fObjectBlock
 counter for blocking calls, as long as non-zero, non of child can be removed More...
 
ReferencesVectorfObjectChilds
 list of the child objects More...
 
unsigned fObjectFlags
 flag, protected by the mutex More...
 
MutexfObjectMutex
 mutex protects all private property of the object More...
 
std::string fObjectName
 object name More...
 
Reference fObjectParent
 reference on the parent object More...
 
int fObjectRefCnt
 accounts how many references existing on the object, thread safe More...
 
- Protected Attributes inherited from dabc::PosixThread
cpu_set_t fCpuSet
 affinity property of the thread More...
 
pthread_t fThrd
 pthread handle More...
 

Static Protected Attributes

static unsigned fThreadInstances = 0
 
- Static Protected Attributes inherited from dabc::PosixThread
static cpu_set_t fDfltSet
 default affinity for new thread More...
 
static cpu_set_t fSpecialSet
 set of processors, which can be used for special threads More...
 

Friends

class ExecWorker
 
class Object
 
class RecursionGuard
 
class ThreadRef
 
class Worker
 

Additional Inherited Members

- Static Protected Member Functions inherited from dabc::Object
static ConstructorPair MakePair (const std::string &fullname, bool withmanager=true)
 Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More...
 
static ConstructorPair MakePair (Object *prnt, const std::string &fullname, bool withmanager=true)
 Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More...
 
static ConstructorPair MakePair (Reference prnt, const std::string &fullname, bool withmanager=true)
 Internal DABC method, used to produce pair - object parent and object name, which is typically should be used as argument in class constructor. More...
 
- Static Protected Member Functions inherited from dabc::PosixThread
static bool GetDfltAffinity (char *buf, unsigned maxbuf)
 Returns default affinity mask in form "xxxooosss". More...
 
static Thread_t Self ()
 
static bool SetDfltAffinity (const char *aff=nullptr)
 Sets default affinity for next threads to be created and for main process. More...
 

Detailed Description

Represent thread functionality.

Definition at line 107 of file Thread.h.

Member Typedef Documentation

◆ WorkersVector

typedef std::vector<WorkerRec*> dabc::Thread::WorkersVector
protected

Definition at line 253 of file Thread.h.

Member Enumeration Documentation

◆ EHaltActions

Enumerator
actDestroy 
actHalt 

Definition at line 272 of file Thread.h.

◆ EThreadState

Enumerator
stCreated 
stRunning 
stStopped 
stError 
stChanging 

Definition at line 274 of file Thread.h.

◆ EEvents

Enumerator
evntCheckTmoutWorker 

event used to process timeout for specific worker, used by ActivateTimeout

evntCheckTmoutAddon 

event used to process timeout for addon, used by ActivateTimeout

evntCleanupThrd 

event will be generated when thread can be destroyed

evntDoNothing 

event fired to wake-up thread and let thread or processor to perform regular checks

evntStopThrd 

event should stop thread

evntLastThrd 
evntUser 

Definition at line 319 of file Thread.h.

◆ EPriority

Enumerator
priorityHighest 
priorityNormal 
priorityLowest 

Definition at line 327 of file Thread.h.

Constructor & Destructor Documentation

◆ Thread()

dabc::Thread::Thread ( Reference  parent,
const std::string &  name,
Command  cmd = nullptr 
)

Definition at line 211 of file Thread.cxx.

◆ ~Thread()

dabc::Thread::~Thread ( )
virtual

Reimplemented in verbs::Thread.

Definition at line 276 of file Thread.cxx.

Member Function Documentation

◆ CheckWorkerCanBeHalted()

int dabc::Thread::CheckWorkerCanBeHalted ( unsigned  id,
unsigned  request = 0,
Command  cmd = nullptr 
)
protected

Internal DABC method, used to verify if worker can be halted now while recursion is over Request indicates that halt action is requested : actDestroy = 1 or actHalt = 2.

Returns true when worker is really halted

Definition at line 929 of file Thread.cxx.

◆ IncWorkerFiredEvents()

void dabc::Thread::IncWorkerFiredEvents ( Worker work)
protected

Definition at line 342 of file Thread.cxx.

◆ RunCommandInTheThread()

int dabc::Thread::RunCommandInTheThread ( Worker caller,
Worker dest,
Command  cmd 
)
protected

Definition at line 517 of file Thread.cxx.

◆ NumThreadInstances()

static unsigned dabc::Thread::NumThreadInstances ( )
inlinestatic

Definition at line 331 of file Thread.h.

◆ MainLoop()

void * dabc::Thread::MainLoop ( )
virtual

Implements dabc::Runnable.

Definition at line 435 of file Thread.cxx.

◆ IsItself()

bool dabc::Thread::IsItself ( ) const
inline

Definition at line 339 of file Thread.h.

◆ SetPriority()

void dabc::Thread::SetPriority ( int  prio = 0)
inline

Definition at line 340 of file Thread.h.

◆ SetStopTimeout()

void dabc::Thread::SetStopTimeout ( double  timeout_sec)
inline

Definition at line 343 of file Thread.h.

◆ GetStopTimeout()

double dabc::Thread::GetStopTimeout ( ) const
inline

Definition at line 344 of file Thread.h.

◆ Start()

bool dabc::Thread::Start ( double  timeout_sec = -1.,
bool  real_thread = true 
)

Definition at line 618 of file Thread.cxx.

◆ Stop()

bool dabc::Thread::Stop ( double  timeout_sec = 10)

Definition at line 690 of file Thread.cxx.

◆ Sync()

bool dabc::Thread::Sync ( double  timeout_sec = -1)

Definition at line 774 of file Thread.cxx.

◆ ClassName()

virtual const char* dabc::Thread::ClassName ( ) const
inlinevirtual

Returns class name of the object instance.

In some cases class name used to correctly locate object in xml file

Reimplemented from dabc::Object.

Reimplemented in verbs::Thread, and dabc::SocketThread.

Definition at line 351 of file Thread.h.

◆ CompatibleClass()

bool dabc::Thread::CompatibleClass ( const std::string &  clname) const
virtual

Reimplemented in verbs::Thread, and dabc::SocketThread.

Definition at line 428 of file Thread.cxx.

◆ FireDoNothingEvent()

void dabc::Thread::FireDoNothingEvent ( )

Definition at line 826 of file Thread.cxx.

◆ Execute()

bool dabc::Thread::Execute ( dabc::Command  cmd,
double  tmout = -1 
)

Definition at line 1220 of file Thread.cxx.

◆ SingleLoop()

bool dabc::Thread::SingleLoop ( unsigned  workerid = 0,
double  tmout = -1 
)

Processes single event from the thread queue.

Workerid indicates context where execution is done, one can throw exception if explicit loop works around Returns false when worker should be halted

Definition at line 468 of file Thread.cxx.

◆ RunEventLoop()

void dabc::Thread::RunEventLoop ( double  tmout = 1.)

Runs thread event loop for specified time.

If time less than 0, event function called at least once. Should be used at the places where user want to sleep inside processor

Definition at line 492 of file Thread.cxx.

◆ Print()

void dabc::Thread::Print ( int  lvl = 0)
virtual

Print thread content on debug output.

Reimplemented from dabc::Object.

Definition at line 1371 of file Thread.cxx.

◆ TotalNumberOfEvents()

unsigned dabc::Thread::TotalNumberOfEvents ( )

Return total number of all events in the queues.

Definition at line 355 of file Thread.cxx.

◆ ThreadMutex()

Mutex* dabc::Thread::ThreadMutex ( ) const
inlineprotected

Definition at line 377 of file Thread.h.

◆ IsTemporaryThread()

bool dabc::Thread::IsTemporaryThread ( ) const
inlineprotected

Returns true is this is temporary thread for command execution.

Definition at line 380 of file Thread.h.

◆ ExecuteThreadCommand()

int dabc::Thread::ExecuteThreadCommand ( Command  cmd)
protectedvirtual

Reimplemented in verbs::Thread.

Definition at line 833 of file Thread.cxx.

◆ WaitEvent()

bool dabc::Thread::WaitEvent ( EventId evid,
double  tmout 
)
protectedvirtual

Reimplemented in dabc::SocketThread, and verbs::Thread.

Definition at line 1044 of file Thread.cxx.

◆ ProcessEvent()

void dabc::Thread::ProcessEvent ( const EventId evnt)
protected

Definition at line 1056 of file Thread.cxx.

◆ ProcessExtraThreadEvent()

virtual void dabc::Thread::ProcessExtraThreadEvent ( const EventId )
inlineprotectedvirtual

Method to process events which are not processed by Thread class itself Should be used in derived classes for their events processing.

Reimplemented in dabc::SocketThread, and verbs::Thread.

Definition at line 390 of file Thread.h.

◆ ProcessNoneEvent()

void dabc::Thread::ProcessNoneEvent ( )
protected

Definition at line 361 of file Thread.cxx.

◆ _GetNextEvent()

bool dabc::Thread::_GetNextEvent ( dabc::EventId evnt)
protected

Definition at line 396 of file Thread.cxx.

◆ RunnableCancelled()

void dabc::Thread::RunnableCancelled ( )
protectedvirtual

Reimplemented from dabc::Runnable.

Definition at line 680 of file Thread.cxx.

◆ _TotalNumberOfEvents()

unsigned dabc::Thread::_TotalNumberOfEvents ( )
protected

Definition at line 347 of file Thread.cxx.

◆ _PushEvent()

void dabc::Thread::_PushEvent ( const EventId arg,
int  nq 
)
inlineprotected

Definition at line 404 of file Thread.h.

◆ _Fire()

void dabc::Thread::_Fire ( const EventId arg,
int  nq 
)
protectedvirtual

Reimplemented in dabc::SocketThread, and verbs::Thread.

Definition at line 1023 of file Thread.cxx.

◆ Fire()

void dabc::Thread::Fire ( const EventId arg,
int  nq 
)
inlineprotected

Definition at line 427 of file Thread.h.

◆ CheckTimeouts()

double dabc::Thread::CheckTimeouts ( bool  forcerecheck = false)
protected

Definition at line 1284 of file Thread.cxx.

◆ AddWorker()

bool dabc::Thread::AddWorker ( Reference  ref,
bool  sync = true 
)
protected

Internal DABC method, Add worker to thread; reference-safe Reference safe means - it is safe to call it as long as reference on thread is exists We use here reference on the worker to ensure that it does not disappear meanwhile.

Definition at line 1213 of file Thread.cxx.

◆ HaltWorker()

bool dabc::Thread::HaltWorker ( Worker proc)
protected

Halt worker - stops any execution, break recursion.

Definition at line 1227 of file Thread.cxx.

◆ WorkerAddonChanged()

void dabc::Thread::WorkerAddonChanged ( Worker work,
bool  assign = true 
)
protected

Called when worker addon changed on the fly.

Definition at line 1241 of file Thread.cxx.

◆ SetExplicitLoop()

bool dabc::Thread::SetExplicitLoop ( Worker work)
protected

Definition at line 779 of file Thread.cxx.

◆ RunExplicitLoop()

void dabc::Thread::RunExplicitLoop ( )
protected

Definition at line 794 of file Thread.cxx.

◆ WorkersSetChanged()

virtual void dabc::Thread::WorkersSetChanged ( )
inlineprotectedvirtual

Virtual method, called from thread context to inform that number of workers are changed.

Can be used by derived class to reorganize its structure

Reimplemented in verbs::Thread, and dabc::SocketThread.

Definition at line 452 of file Thread.h.

◆ InvokeWorkerDestroy()

bool dabc::Thread::InvokeWorkerDestroy ( Worker work)
protected

Cleanup object asynchronously.

This allows to call object cleanup from the thread where it processed. It can be processor which will be removed

Definition at line 1268 of file Thread.cxx.

◆ ChangeRecursion()

void dabc::Thread::ChangeRecursion ( unsigned  id,
bool  inc 
)
protected

Method which allows to control recursion of each worker.

If worker must be destroyed or halted, this is allowed only with zero recursion

Definition at line 909 of file Thread.cxx.

◆ ObjectCleanup()

void dabc::Thread::ObjectCleanup ( )
protectedvirtual

Cleanup thread that manager is allowed to delete it.

Reimplemented from dabc::Object.

Definition at line 1329 of file Thread.cxx.

◆ _DoDeleteItself()

bool dabc::Thread::_DoDeleteItself ( )
protectedvirtual

This method is called at the moment when DecReference think that object can be destroyed and wants to return true.

Object can decide to find another way to the destructor and reject this. After _DoDeleteItself() returns true, it is fully object responsibility to delete itself.

Reimplemented from dabc::Object.

Definition at line 1355 of file Thread.cxx.

◆ NumWorkers()

unsigned dabc::Thread::NumWorkers ( )
protected

Returns actual number of workers.

Definition at line 1387 of file Thread.cxx.

Friends And Related Function Documentation

◆ Worker

friend class Worker
friend

Definition at line 112 of file Thread.h.

◆ ThreadRef

friend class ThreadRef
friend

Definition at line 113 of file Thread.h.

◆ ExecWorker

friend class ExecWorker
friend

Definition at line 268 of file Thread.h.

◆ Object

friend class Object
friend

Definition at line 269 of file Thread.h.

◆ RecursionGuard

friend class RecursionGuard
friend

Definition at line 270 of file Thread.h.

Field Documentation

◆ fState

EThreadState dabc::Thread::fState
protected

actual thread state

Definition at line 276 of file Thread.h.

◆ fThrdWorking

bool dabc::Thread::fThrdWorking
protected

flag indicates if mainloop of the thread should continue to work

Definition at line 278 of file Thread.h.

◆ fRealThrd

bool dabc::Thread::fRealThrd
protected

indicate if we create real thread and not running mainloop from top process

Definition at line 279 of file Thread.h.

◆ fWorkCond

Condition dabc::Thread::fWorkCond
protected

condition, which is used in default MainLoop implementation

Definition at line 281 of file Thread.h.

◆ fQueues

EventsQueue* dabc::Thread::fQueues
protected

queues for threads events

Definition at line 283 of file Thread.h.

◆ fNumQueues

int dabc::Thread::fNumQueues
protected

number of queues

Definition at line 284 of file Thread.h.

◆ fNextTimeout

TimeStamp dabc::Thread::fNextTimeout
protected

indicate when we expects next timeout

Definition at line 286 of file Thread.h.

◆ fProcessingTimeouts

int dabc::Thread::fProcessingTimeouts
protected

indicate recursion in timeouts processing

Definition at line 287 of file Thread.h.

◆ fWorkers

WorkersVector dabc::Thread::fWorkers
protected

vector of all processors

Definition at line 289 of file Thread.h.

◆ fExplicitLoop

unsigned dabc::Thread::fExplicitLoop
protected

id of the worker, selected to run own explicit loop

Definition at line 291 of file Thread.h.

◆ fExec

ExecWorker* dabc::Thread::fExec
protected

processor to execute commands in the thread

Definition at line 293 of file Thread.h.

◆ fDidDecRefCnt

bool dabc::Thread::fDidDecRefCnt
protected

indicates if object cleanup was called - need in destructor

Definition at line 294 of file Thread.h.

◆ fCheckThrdCleanup

bool dabc::Thread::fCheckThrdCleanup
protected

indicates if thread should be checked for clean up

Definition at line 295 of file Thread.h.

◆ fProfiling

bool dabc::Thread::fProfiling
protected

if true, different statistic will be accumulated about thread

Definition at line 297 of file Thread.h.

◆ fLastProfileTime

TimeStamp dabc::Thread::fLastProfileTime
protected

when doing profiling, last time when profiling was done

Definition at line 298 of file Thread.h.

◆ fThreadRunTime

double dabc::Thread::fThreadRunTime
protected

total run time (user and sys), measured by getrusage

Definition at line 299 of file Thread.h.

◆ fThrdStopTimeout

double dabc::Thread::fThrdStopTimeout
protected

time in second set as timeout when stopping thred

Definition at line 301 of file Thread.h.

◆ fThreadInstances

unsigned dabc::Thread::fThreadInstances = 0
staticprotected

Definition at line 303 of file Thread.h.


The documentation for this class was generated from the following files: