LRAUV  revA
ControlThread.h
Go to the documentation of this file.
1 
9 #ifndef CONTROLTHREAD_H_
10 #define CONTROLTHREAD_H_
11 
14 #include "process/SyncHandler.h"
15 
16 static const double DEFAULT_CONTROL_THREAD_PERIOD = 0.4;
17 
18 class ControlThread;
19 
39 {
40 public:
42  ControlThread();
43 
45  virtual ~ControlThread();
46 
48  virtual void initialize( void );
49 
51  virtual void run( void );
52 
54  virtual void uninitialize( void );
55 
56  //== Functions for dealing with the list of components ==
61  void addComponent( SyncComponent *component );
62 
68  void removeComponent( SyncComponent *component );
69 
72  {
73  return & syncHandler_;
74  }
75 
76 private:
77 
79 
80  // Hm, ok, what if there were three lists, an "add me" list,
81  // a "delete me" list and an actual "working" list. Then
82  // the thread could decide when to take action...
83  //
84  // It's possible that some of these lists will actually be of
85  // intermediate "holder" objects to hold counts, metainfo, etc...
89 
94  int addComponentsFromQueue( void );
95 
100  int removeComponentsFromQueue( void );
101 };
102 
103 
104 #endif /*CONTROLTHREAD_H_*/
Contains the SyncComponent class definition.
SyncHandler syncHandler_
Definition: ControlThread.h:78
virtual Handler * getSyncHandler()
Returns the Handler associated with this component.
Definition: ControlThread.h:71
virtual void run(void)
Run the thread.
Definition: ControlThread.cpp:43
Mutex addComponentsMutex_
Definition: ControlThread.h:88
int removeComponentsFromQueue(void)
Takes any components in the componentsToRemove_ queue, uninitializes them and removes them from the c...
Definition: ControlThread.cpp:106
A simple pthread Mutex abstraction.
Definition: Mutex.h:20
virtual void uninitialize(void)
Uninitialize the component.
Definition: ControlThread.cpp:64
void addComponent(SyncComponent *component)
Put a component in the control thread's control.
Definition: ControlThread.cpp:73
Contains the SyncHandler class declaration.
ListOfSyncComponents componentsToRemove_
Definition: ControlThread.h:87
ListOfSyncComponents componentsToAdd_
Definition: ControlThread.h:86
ControlThread()
Constructor.
Definition: ControlThread.cpp:13
Abstract Base class for software components that run in the computation cycle.
Definition: SyncComponent.h:22
virtual void initialize(void)
Initialize the component.
Definition: ControlThread.cpp:27
Base class for "handlers" of Components.
Definition: Handler.h:49
Mutex removeComponentsMutex_
Definition: ControlThread.h:88
int addComponentsFromQueue(void)
Takes any new components in the componentsToAdd_ queue,initializes them, and adds them to the control...
Definition: ControlThread.cpp:86
void removeComponent(SyncComponent *component)
Remove a component from the control thread's control.
Definition: ControlThread.cpp:80
Abstract Base class for software components that run independently from the computation cycle...
Definition: AsyncComponent.h:20
virtual ~ControlThread()
Destructor.
Definition: ControlThread.cpp:23
The SyncHandler and ControlThread are a bit of a strange arrangement.
Definition: SyncHandler.h:31
The periodic "control thread".
Definition: ControlThread.h:38
Contains the AsyncComponent class definition.