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

Active object, which is working inside dabc::Thread. More...

#include <dabc/Worker.h>

Inheritance diagram for dabc::Worker:
dabc::Object dabc::Application dabc::Device dabc::Manager dabc::Module dabc::ModuleItem dabc::Publisher dabc::SocketCommandChannel dabc::SocketCommandClient dabc::Thread::ExecWorker http::Server mbs::DaqLogWorker mbs::DaqRemCmdWorker mbs::PrompterWorker root::Monitor verbs::TimeoutWorker

Public Types

enum  EPriotiryLevels { priorityMaximum = 0 , priorityMinimum = -1 , priorityDefault = -7 , priorityMagic = -77 }
 
enum  EWorkerEventsCodes { evntFirstCore = 1 , evntFirstAddOn = 100 , evntFirstSystem = 200 , evntFirstUser = 1000 }
 

Public Member Functions

bool ActivateTimeout (double tmout_sec)
 Method used to produce timeout events in the worker. More...
 
Command Assign (Command cmd)
 ! Assign command with processor before command be submitted to other processor This produce ReplyCommand() call when command execution is finished Command itself returned if operation was successful, otherwise null() command More...
 
void AssignAddon (WorkerAddon *addon)
 Assigns addon to the worker Should be called before worker assigned to the thread. More...
 
bool AssignToThread (ThreadRef thrd, bool sync=true)
 Assign worker to thread, worker becomes active immediately. More...
 
bool CanSubmitCommand () const
 Returns true if command can be submitted to worker. More...
 
RecordField Cfg (const std::string &name, Command cmd=nullptr) const
 Returns configuration field of specified name Configuration value of specified name searched in following places: More...
 
virtual const char * ClassName () const
 Returns class name of the object instance. More...
 
bool DettachFromThread ()
 Detach worker from the thread, later worker can be assigned to some other thread Method especially useful to normally finish object recursion (if it possible). More...
 
bool Execute (Command cmd, double tmout=-1.)
 Execute command in the processor. More...
 
bool Execute (const std::string &cmd, double tmout=-1.)
 
bool HasThread () const
 Indicates if pointer on thread is not zero; thread-safe. More...
 
bool IsOwnThread () const
 Returns true if called from thread. More...
 
bool MakeThreadForWorker (const std::string &thrdname="")
 Creates appropriate thread for worker and assign worker to the thread. More...
 
Parameter Par (const std::string &name) const
 Returns reference on worker parameter object. More...
 
virtual std::string RequiredThrdClass () const
 Method returns name of required thread class for processor. More...
 
void SetWorkerPriority (int nq)
 
bool Submit (Command cmd)
 Submit command for execution in the processor. More...
 
ThreadRef thread ()
 Return reference on the worker thread; thread-safe. More...
 
std::string ThreadName () const
 Returns name of the worker thread; thread-safe
More...
 
 Worker (Reference parent, const std::string &name)
 
std::string WorkerAddress (bool full=true)
 Return address, which can be used to submit command to the worker If full specified, command can be submitted from any node, which has connection to this node. More...
 
uint32_t WorkerId () const
 
int WorkerPriority () const
 
virtual ~Worker ()
 
- 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...
 
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)
 
virtual void Print (int lvl=0)
 Print object content on debug output. More...
 
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 int cmd_bool (bool v)
 
- 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 Member Functions

bool _FireDoNothingEvent ()
 
bool _FireEvent (uint16_t evid)
 
bool _FireEvent (uint16_t evid, uint32_t arg, int pri=-1)
 
bool _IsFireEvent () const
 
bool ActivateMainLoop ()
 
virtual void BeforeHierarchyScan (Hierarchy &h)
 Method called before publisher makes next snapshot of hierarchy. More...
 
void CancelCommands ()
 
void CleanupPublisher (bool sync=true)
 Release reference on publisher and unsubscribe/unpublish all registered entries. More...
 
CommandDefinition CreateCmdDef (const std::string &name)
 
virtual Parameter CreatePar (const std::string &name, const std::string &kind="")
 
virtual bool DestroyByOwnThread ()
 Inherited method from Object, invoked at the moment when worker requested to be destroyed by its thread. More...
 
bool DestroyPar (const std::string &name)
 Method must be used if worker wants to destroy parameter. More...
 
virtual void DoWorkerAfterMainLoop ()
 Internal - function executed after leaving main loop. More...
 
virtual void DoWorkerMainLoop ()
 Internal - entrance function for main loop execution. More...
 
virtual int ExecuteCommand (Command cmd)
 Main method where commands are executed. More...
 
bool ExecuteIn (Worker *dest, Command cmd)
 Executes command in specified worker. More...
 
virtual bool Find (ConfigIO &cfg)
 Method to locate object in xml file. More...
 
bool FireEvent (uint16_t evid)
 
bool FireEvent (uint16_t evid, uint32_t arg, int pri=-1)
 
Reference GetPublisher ()
 Return reference on publisher. More...
 
bool IsWorkerActive () const
 Method indicates if worker is running in the thread and accepts normal events. More...
 
virtual void ObjectCleanup ()
 Central cleanup method for worker. More...
 
virtual void ObjectDestroyed (Object *)
 Method to clear object reference, will be called from thread context (when possible) More...
 
virtual void OnThreadAssigned ()
 
virtual int PreviewCommand (Command cmd)
 This method called before command will be executed. More...
 
virtual void ProcessEvent (const EventId &)
 
virtual void ProcessParameterEvent (const ParameterEvent &evnt)
 Interface method to retrieve subscribed parameter events. More...
 
virtual double ProcessTimeout (double last_diff)
 
virtual bool Publish (const Hierarchy &h, const std::string &path)
 
virtual bool PublishPars (const std::string &path)
 
bool RegisterForParameterEvent (const std::string &mask, bool onlychangeevent=true)
 Subscribe to parameter events from local or remote node. More...
 
virtual bool ReplyCommand (Command cmd)
 Reimplement this method to react on command reply Return true if command can be destroyed by framework. More...
 
void SetParValue (const std::string &name, const RecordField &v)
 Set parameter value and sync with worker hierarchy. More...
 
void SetWorkerCfgId (int id=-1)
 Set identifier which can be used in XML configuration ${}# formula It means that correspondent to the ID element of array will be extracted. More...
 
bool SingleLoop (double tmout)
 
virtual bool Subscribe (const std::string &path)
 
virtual bool Unpublish (const Hierarchy &h, const std::string &path)
 
bool UnregisterForParameterEvent (const std::string &mask)
 Unsubscribe to parameter events from local or remote node. More...
 
virtual bool Unsubscribe (const std::string &path)
 
 Worker (const ConstructorPair &pair)
 Special constructor, designed for inherited classes. More...
 
void WorkerSleep (double tmout)
 
- Protected Member Functions inherited from dabc::Object
virtual void _ChildsChanged ()
 Method called when new childs are add or old are removed. More...
 
virtual bool _DoDeleteItself ()
 This method is called at the moment when DecReference think that object can be destroyed and wants to return true. 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...
 
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)
 
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 Attributes

WorkerAddonRef fAddon
 extension of worker for some special events More...
 
Reference fPublisher
 reference on publisher, once found, remain until end of object live More...
 
ThreadRef fThread
 reference on the thread, once assigned remain whole time More...
 
MutexfThreadMutex
 pointer on main thread mutex More...
 
bool fWorkerActive
 indicates if worker can submit events to the thread More...
 
int fWorkerCfgId
 special ID, can be used in XML configuration in ${}# formula More...
 
CommandsQueue fWorkerCommands
 all kinds of commands, processed by the worker More...
 
int fWorkerCommandsLevel
 Number of process commands recursion. More...
 
unsigned fWorkerFiredEvents
 indicate current balance between fired and processed events, used to correctly halt worker More...
 
Hierarchy fWorkerHierarchy
 place for publishing of worker parameters More...
 
uint32_t fWorkerId
 worker id in thread list, used for events submit More...
 
int fWorkerPriority
 priority of events, submitted by worker to the thread 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...
 

Private Types

enum  { evntSubmitCommand = evntFirstCore , evntReplyCommand }
 
enum  EParsMasks { parsVisibilityMask = 0xFF , parsFixedMask = 0x100 , parsChangableMask = 0x200 , parsValidMask = 0x400 }
 

Private Member Functions

void ClearThreadRef ()
 Method to 'forget' thread reference. More...
 
bool GetCommandReply (dabc::Command &cmd, bool *exe_ready)
 
void InformThreadAssigned ()
 Method called from the thread to inform Worker when it is assigned to thread. More...
 
double ProcessAddonTimeout (double last_diff)
 
int ProcessCommand (dabc::Command cmd)
 
void ProcessCoreEvent (EventId)
 
void ProcessParameterRecording (ParameterContainer *par)
 Method to process parameter recording in worker thread. More...
 
void WorkerParameterChanged (bool forcecall, ParameterContainer *par, const std::string &value)
 Method called by parameter object which is belong to the worker. More...
 

Friends

class Command
 
class Object
 
class Parameter
 
class ParameterContainer
 
class Thread
 
class WorkerAddon
 
class WorkerRef
 

Additional Inherited Members

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

Detailed Description

Active object, which is working inside dabc::Thread.

Definition at line 116 of file Worker.h.

Member Enumeration Documentation

◆ EParsMasks

Enumerator
parsVisibilityMask 
parsFixedMask 
parsChangableMask 
parsValidMask 

Definition at line 118 of file Worker.h.

◆ EWorkerEventsCodes

Enumerator
evntFirstCore 
evntFirstAddOn 
evntFirstSystem 
evntFirstUser 

Definition at line 199 of file Worker.h.

◆ EPriotiryLevels

Enumerator
priorityMaximum 
priorityMinimum 
priorityDefault 
priorityMagic 

Definition at line 206 of file Worker.h.

◆ anonymous enum

anonymous enum
private
Enumerator
evntSubmitCommand 
evntReplyCommand 

Definition at line 441 of file Worker.h.

Constructor & Destructor Documentation

◆ Worker() [1/2]

dabc::Worker::Worker ( const ConstructorPair pair)
protected

Special constructor, designed for inherited classes.

Definition at line 109 of file Worker.cxx.

◆ Worker() [2/2]

dabc::Worker::Worker ( Reference  parent,
const std::string &  name 
)

Definition at line 83 of file Worker.cxx.

◆ ~Worker()

dabc::Worker::~Worker ( )
virtual

Definition at line 133 of file Worker.cxx.

Member Function Documentation

◆ ClearThreadRef()

void dabc::Worker::ClearThreadRef ( )
private

Method to 'forget' thread reference.

Definition at line 213 of file Worker.cxx.

◆ InformThreadAssigned()

void dabc::Worker::InformThreadAssigned ( )
inlineprivate

Method called from the thread to inform Worker when it is assigned to thread.

Definition at line 139 of file Worker.h.

◆ ProcessAddonTimeout()

double dabc::Worker::ProcessAddonTimeout ( double  last_diff)
inlineprivate

Definition at line 145 of file Worker.h.

◆ DestroyByOwnThread()

bool dabc::Worker::DestroyByOwnThread ( )
protectedvirtual

Inherited method from Object, invoked at the moment when worker requested to be destroyed by its thread.

Reimplemented from dabc::Object.

Reimplemented in saftdabc::Device.

Definition at line 194 of file Worker.cxx.

◆ ObjectCleanup()

void dabc::Worker::ObjectCleanup ( )
protectedvirtual

Central cleanup method for worker.

Reimplemented from dabc::Object.

Reimplemented in saftdabc::Device, dabc::PoolHandle, dabc::Port, dabc::ModuleSync, dabc::Module, dabc::Device, and dabc::Application.

Definition at line 238 of file Worker.cxx.

◆ ObjectDestroyed()

virtual void dabc::Worker::ObjectDestroyed ( Object )
inlineprotectedvirtual

Method to clear object reference, will be called from thread context (when possible)

Reimplemented from dabc::Object.

Definition at line 180 of file Worker.h.

◆ IsWorkerActive()

bool dabc::Worker::IsWorkerActive ( ) const
inlineprotected

Method indicates if worker is running in the thread and accepts normal events.

All events accepted by the worker will be delivered and processed. If destruction or halt of the worker starts, no new events can be submitted (execpt command with magic priority) In this phase IsWorkerActive() will already return false

Definition at line 186 of file Worker.h.

◆ SetWorkerCfgId()

void dabc::Worker::SetWorkerCfgId ( int  id = -1)
inlineprotected

Set identifier which can be used in XML configuration ${}# formula It means that correspondent to the ID element of array will be extracted.

Definition at line 190 of file Worker.h.

◆ cmd_bool()

static int dabc::Worker::cmd_bool ( bool  v)
inlinestatic

Definition at line 197 of file Worker.h.

◆ ClassName()

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

◆ RequiredThrdClass()

virtual std::string dabc::Worker::RequiredThrdClass ( ) const
inlinevirtual

Method returns name of required thread class for processor.

If returns empty string, any thread class is sufficient.

Reimplemented in mbs::Monitor, mbs::DaqLogWorker, dabc::SocketDevice, and dabc::SocketCommandChannel.

Definition at line 220 of file Worker.h.

◆ HasThread()

bool dabc::Worker::HasThread ( ) const

Indicates if pointer on thread is not zero; thread-safe.

Definition at line 151 of file Worker.cxx.

◆ IsOwnThread()

bool dabc::Worker::IsOwnThread ( ) const

Returns true if called from thread.

If thread not assigned, also returns true

Definition at line 176 of file Worker.cxx.

◆ AssignToThread()

bool dabc::Worker::AssignToThread ( ThreadRef  thrd,
bool  sync = true 
)

Assign worker to thread, worker becomes active immediately.

Definition at line 326 of file Worker.cxx.

◆ MakeThreadForWorker()

bool dabc::Worker::MakeThreadForWorker ( const std::string &  thrdname = "")

Creates appropriate thread for worker and assign worker to the thread.

Definition at line 302 of file Worker.cxx.

◆ DettachFromThread()

bool dabc::Worker::DettachFromThread ( )

Detach worker from the thread, later worker can be assigned to some other thread Method especially useful to normally finish object recursion (if it possible).

If successful, object can be assigned to new thread again or destroyed. Worker halt (recursion break) is also performed during object destroyment, therefore it is not necessary to call this method before destroy of the worker

Definition at line 372 of file Worker.cxx.

◆ thread()

dabc::ThreadRef dabc::Worker::thread ( )

Return reference on the worker thread; thread-safe.

Definition at line 158 of file Worker.cxx.

◆ ThreadName()

std::string dabc::Worker::ThreadName ( ) const

Returns name of the worker thread; thread-safe

Definition at line 186 of file Worker.cxx.

◆ ActivateTimeout()

bool dabc::Worker::ActivateTimeout ( double  tmout_sec)

Method used to produce timeout events in the worker.

After specified time interval ProcessTimeout() method of worker will be called.

Parameters
[in]tmout_sechas following meaning: = 0 ProcessTimeout() will be called as soon as possible < 0 deactivate if possible previously scheduled timeout

0 activate after specified interval

Returns
false if timeout cannot be configured (when thread is not assigned or not active)

Definition at line 385 of file Worker.cxx.

◆ SetWorkerPriority()

void dabc::Worker::SetWorkerPriority ( int  nq)
inline

Definition at line 259 of file Worker.h.

◆ WorkerPriority()

int dabc::Worker::WorkerPriority ( ) const
inline

Definition at line 260 of file Worker.h.

◆ WorkerId()

uint32_t dabc::Worker::WorkerId ( ) const
inline

Definition at line 262 of file Worker.h.

◆ Par()

dabc::Parameter dabc::Worker::Par ( const std::string &  name) const

Returns reference on worker parameter object.

Definition at line 516 of file Worker.cxx.

◆ Cfg()

dabc::RecordField dabc::Worker::Cfg ( const std::string &  name,
Command  cmd = nullptr 
) const

Returns configuration field of specified name Configuration value of specified name searched in following places:

  1. As field in command
  2. As parameter value in the worker itself
  3. As value in xml file
  4. As parameter value of all parents

Definition at line 521 of file Worker.cxx.

◆ Assign()

dabc::Command dabc::Worker::Assign ( dabc::Command  cmd)

! Assign command with processor before command be submitted to other processor This produce ReplyCommand() call when command execution is finished Command itself returned if operation was successful, otherwise null() command

Definition at line 933 of file Worker.cxx.

◆ CanSubmitCommand()

bool dabc::Worker::CanSubmitCommand ( ) const

Returns true if command can be submitted to worker.

Definition at line 953 of file Worker.cxx.

◆ Submit()

bool dabc::Worker::Submit ( dabc::Command  cmd)

Submit command for execution in the processor.

Definition at line 960 of file Worker.cxx.

◆ Execute() [1/2]

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

Execute command in the processor.

Event loop of caller thread is kept running

Definition at line 877 of file Worker.cxx.

◆ Execute() [2/2]

bool dabc::Worker::Execute ( const std::string &  cmd,
double  tmout = -1. 
)
inline

Definition at line 292 of file Worker.h.

◆ WorkerAddress()

std::string dabc::Worker::WorkerAddress ( bool  full = true)

Return address, which can be used to submit command to the worker If full specified, command can be submitted from any node, which has connection to this node.

Definition at line 1062 of file Worker.cxx.

◆ AssignAddon()

void dabc::Worker::AssignAddon ( WorkerAddon addon)

Assigns addon to the worker Should be called before worker assigned to the thread.

Definition at line 277 of file Worker.cxx.

◆ PreviewCommand()

int dabc::Worker::PreviewCommand ( Command  cmd)
protectedvirtual

This method called before command will be executed.

Only if cmd_ignore is returned, ExecuteCommand will be called for this command Otherwise command is replied with returned value Contrary to ExecuteCommand, PreviewCommand used by dabc classes itself. Therefore, if method redefined in inherited class, one should always call PreviewCommand of base class first.

Reimplemented in dabc::SocketCommandChannel, dabc::ModuleSync, dabc::Module, and dabc::Manager.

Definition at line 650 of file Worker.cxx.

◆ ExecuteCommand()

int dabc::Worker::ExecuteCommand ( Command  cmd)
protectedvirtual

◆ ReplyCommand()

bool dabc::Worker::ReplyCommand ( Command  cmd)
protectedvirtual

Reimplement this method to react on command reply Return true if command can be destroyed by framework.

Reimplemented in hadaq::CombinerModule, hadaq::TerminalModule, hadaq::BnetMasterModule, dabc::SocketCommandClient, dabc::Publisher, dabc::Module, dabc::Manager, dabc::ConnectionManager, and dabc::Application.

Definition at line 856 of file Worker.cxx.

◆ ProcessTimeout()

virtual double dabc::Worker::ProcessTimeout ( double  last_diff)
inlineprotectedvirtual

◆ _IsFireEvent()

bool dabc::Worker::_IsFireEvent ( ) const
inlineprotected

Definition at line 328 of file Worker.h.

◆ _FireEvent() [1/2]

bool dabc::Worker::_FireEvent ( uint16_t  evid)
inlineprotected

Definition at line 333 of file Worker.h.

◆ FireEvent() [1/2]

bool dabc::Worker::FireEvent ( uint16_t  evid)
inlineprotected

Definition at line 341 of file Worker.h.

◆ _FireEvent() [2/2]

bool dabc::Worker::_FireEvent ( uint16_t  evid,
uint32_t  arg,
int  pri = -1 
)
inlineprotected

Definition at line 347 of file Worker.h.

◆ FireEvent() [2/2]

bool dabc::Worker::FireEvent ( uint16_t  evid,
uint32_t  arg,
int  pri = -1 
)
inlineprotected

Definition at line 355 of file Worker.h.

◆ _FireDoNothingEvent()

bool dabc::Worker::_FireDoNothingEvent ( )
inlineprotected

Definition at line 362 of file Worker.h.

◆ ProcessEvent()

void dabc::Worker::ProcessEvent ( const EventId evnt)
protectedvirtual

◆ ActivateMainLoop()

bool dabc::Worker::ActivateMainLoop ( )
protected

Definition at line 505 of file Worker.cxx.

◆ SingleLoop()

bool dabc::Worker::SingleLoop ( double  tmout)
inlineprotected

Definition at line 373 of file Worker.h.

◆ WorkerSleep()

void dabc::Worker::WorkerSleep ( double  tmout)
protected

Definition at line 1031 of file Worker.cxx.

◆ ExecuteIn()

bool dabc::Worker::ExecuteIn ( dabc::Worker dest,
dabc::Command  cmd 
)
protected

Executes command in specified worker.

This method should be used to execute command synchronously from processor itself.

Call allowed only from worker thread (therefore method protected). Makes it easy to recognize caller thread and keep its event loop running. Equivalent to dest->Execute(cmd).

Method let thread event loop running.

Definition at line 866 of file Worker.cxx.

◆ CancelCommands()

void dabc::Worker::CancelCommands ( )
protected

Definition at line 1026 of file Worker.cxx.

◆ DoWorkerMainLoop()

virtual void dabc::Worker::DoWorkerMainLoop ( )
inlineprotectedvirtual

Internal - entrance function for main loop execution.

Reimplemented in dabc::ModuleSync.

Definition at line 385 of file Worker.h.

◆ DoWorkerAfterMainLoop()

virtual void dabc::Worker::DoWorkerAfterMainLoop ( )
inlineprotectedvirtual

Internal - function executed after leaving main loop.

Reimplemented in dabc::ModuleSync.

Definition at line 388 of file Worker.h.

◆ OnThreadAssigned()

virtual void dabc::Worker::OnThreadAssigned ( )
inlineprotectedvirtual

◆ Find()

bool dabc::Worker::Find ( ConfigIO cfg)
protectedvirtual

Method to locate object in xml file.

Can be reimplemented in derived classes to check more attributes like class name

Reimplemented from dabc::Object.

Reimplemented in dabc::Thread::ExecWorker, dabc::Module, dabc::MemoryPool, dabc::Manager, dabc::Device, and dabc::Application.

Definition at line 608 of file Worker.cxx.

◆ CreatePar()

dabc::Parameter dabc::Worker::CreatePar ( const std::string &  name,
const std::string &  kind = "" 
)
protectedvirtual

Reimplemented in dabc::Module.

Definition at line 558 of file Worker.cxx.

◆ SetParValue()

void dabc::Worker::SetParValue ( const std::string &  name,
const RecordField v 
)
protected

Set parameter value and sync with worker hierarchy.

Definition at line 578 of file Worker.cxx.

◆ CreateCmdDef()

dabc::CommandDefinition dabc::Worker::CreateCmdDef ( const std::string &  name)
protected

Definition at line 603 of file Worker.cxx.

◆ DestroyPar()

bool dabc::Worker::DestroyPar ( const std::string &  name)
protected

Method must be used if worker wants to destroy parameter.

Definition at line 592 of file Worker.cxx.

◆ RegisterForParameterEvent()

bool dabc::Worker::RegisterForParameterEvent ( const std::string &  mask,
bool  onlychangeevent = true 
)
protected

Subscribe to parameter events from local or remote node.

Definition at line 1050 of file Worker.cxx.

◆ UnregisterForParameterEvent()

bool dabc::Worker::UnregisterForParameterEvent ( const std::string &  mask)
protected

Unsubscribe to parameter events from local or remote node.

Definition at line 1056 of file Worker.cxx.

◆ ProcessParameterEvent()

virtual void dabc::Worker::ProcessParameterEvent ( const ParameterEvent evnt)
inlineprotectedvirtual

Interface method to retrieve subscribed parameter events.

Reimplemented in dabc::ConnectionManager.

Definition at line 413 of file Worker.h.

◆ GetPublisher()

dabc::Reference dabc::Worker::GetPublisher ( )
protected

Return reference on publisher.

First time publisher is searched in objects hierarchy and reference stored in the internal structures. User can call CleanupPublisher to clean reference and unsubscribe/unpublish all registered structures.

Definition at line 1068 of file Worker.cxx.

◆ Publish()

bool dabc::Worker::Publish ( const Hierarchy h,
const std::string &  path 
)
protectedvirtual

Definition at line 1075 of file Worker.cxx.

◆ PublishPars()

bool dabc::Worker::PublishPars ( const std::string &  path)
protectedvirtual

Definition at line 1081 of file Worker.cxx.

◆ Unpublish()

bool dabc::Worker::Unpublish ( const Hierarchy h,
const std::string &  path 
)
protectedvirtual

Definition at line 1111 of file Worker.cxx.

◆ Subscribe()

bool dabc::Worker::Subscribe ( const std::string &  path)
protectedvirtual

Definition at line 1116 of file Worker.cxx.

◆ Unsubscribe()

bool dabc::Worker::Unsubscribe ( const std::string &  path)
protectedvirtual

Definition at line 1121 of file Worker.cxx.

◆ CleanupPublisher()

void dabc::Worker::CleanupPublisher ( bool  sync = true)
protected

Release reference on publisher and unsubscribe/unpublish all registered entries.

Definition at line 1126 of file Worker.cxx.

◆ BeforeHierarchyScan()

virtual void dabc::Worker::BeforeHierarchyScan ( Hierarchy h)
inlineprotectedvirtual

Method called before publisher makes next snapshot of hierarchy.

Worker is able to make any kind of changes

Reimplemented in dabc::Thread::ExecWorker.

Definition at line 437 of file Worker.h.

◆ ProcessCoreEvent()

void dabc::Worker::ProcessCoreEvent ( EventId  evnt)
private

Definition at line 392 of file Worker.cxx.

◆ ProcessCommand()

int dabc::Worker::ProcessCommand ( dabc::Command  cmd)
private

Definition at line 449 of file Worker.cxx.

◆ GetCommandReply()

bool dabc::Worker::GetCommandReply ( dabc::Command cmd,
bool *  exe_ready 
)
private

Definition at line 996 of file Worker.cxx.

◆ WorkerParameterChanged()

void dabc::Worker::WorkerParameterChanged ( bool  forcecall,
ParameterContainer par,
const std::string &  value 
)
private

Method called by parameter object which is belong to the worker.

Method is called from the thread where parameter is changing - it could be not a worker thread. Means one should use protected by the mutex worker fields. If monitoring field for parameter is specified, ParameterEvent will be to the worker thread

Definition at line 620 of file Worker.cxx.

◆ ProcessParameterRecording()

void dabc::Worker::ProcessParameterRecording ( ParameterContainer par)
private

Method to process parameter recording in worker thread.

Definition at line 638 of file Worker.cxx.

Friends And Related Function Documentation

◆ Thread

friend class Thread
friend

Definition at line 125 of file Worker.h.

◆ Parameter

friend class Parameter
friend

Definition at line 126 of file Worker.h.

◆ ParameterContainer

friend class ParameterContainer
friend

Definition at line 127 of file Worker.h.

◆ Command

friend class Command
friend

Definition at line 128 of file Worker.h.

◆ Object

friend class Object
friend

Definition at line 129 of file Worker.h.

◆ WorkerRef

friend class WorkerRef
friend

Definition at line 130 of file Worker.h.

◆ WorkerAddon

friend class WorkerAddon
friend

Definition at line 131 of file Worker.h.

Field Documentation

◆ fThread

ThreadRef dabc::Worker::fThread
protected

reference on the thread, once assigned remain whole time

Definition at line 151 of file Worker.h.

◆ fAddon

WorkerAddonRef dabc::Worker::fAddon
protected

extension of worker for some special events

Definition at line 152 of file Worker.h.

◆ fPublisher

Reference dabc::Worker::fPublisher
protected

reference on publisher, once found, remain until end of object live

Definition at line 153 of file Worker.h.

◆ fWorkerId

uint32_t dabc::Worker::fWorkerId
protected

worker id in thread list, used for events submit

Definition at line 155 of file Worker.h.

◆ fWorkerPriority

int dabc::Worker::fWorkerPriority
protected

priority of events, submitted by worker to the thread

Definition at line 156 of file Worker.h.

◆ fThreadMutex

Mutex* dabc::Worker::fThreadMutex
protected

pointer on main thread mutex

Definition at line 158 of file Worker.h.

◆ fWorkerActive

bool dabc::Worker::fWorkerActive
protected

indicates if worker can submit events to the thread

Definition at line 161 of file Worker.h.

◆ fWorkerFiredEvents

unsigned dabc::Worker::fWorkerFiredEvents
protected

indicate current balance between fired and processed events, used to correctly halt worker

Definition at line 162 of file Worker.h.

◆ fWorkerCommands

CommandsQueue dabc::Worker::fWorkerCommands
protected

all kinds of commands, processed by the worker

Definition at line 164 of file Worker.h.

◆ fWorkerCommandsLevel

int dabc::Worker::fWorkerCommandsLevel
protected

Number of process commands recursion.

Definition at line 166 of file Worker.h.

◆ fWorkerHierarchy

Hierarchy dabc::Worker::fWorkerHierarchy
protected

place for publishing of worker parameters

Definition at line 168 of file Worker.h.

◆ fWorkerCfgId

int dabc::Worker::fWorkerCfgId
protected

special ID, can be used in XML configuration in ${}# formula

Definition at line 170 of file Worker.h.


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