My Project
|
#include <GenericTask.h>
Public Member Functions | |
void | sendRestartMsg () |
void | sendStopMsg () |
void | sendHeartBeatMsg () |
virtual void | fwdTaskMsg (Msg *msg) |
Protected Member Functions | |
GenericTask () | |
GenericTask (Thread *thread) | |
virtual | ~GenericTask () |
void | sendTaskMsg (Msg *msg) |
void | startThreads (void *arg) |
void | startThread (void *arg, unsigned order) |
unsigned | getMinStartOrder () |
bool | threadsNeedStarting () |
void | cancelThreads () |
void | cancelThread (unsigned order) |
unsigned | getMinCancelOrder () |
bool | threadsNeedCancelling () |
void | pingThreads (void *arg) |
void | raise (std::string name, int sigNo) |
Thread * | getThread (std::string name) |
bool | threadsAreRunning () |
void | shutdownConnection (int fd) |
virtual void | serviceMsgQ (void) |
virtual void | restart (void) |
virtual void | run (void) |
virtual void | processTaskMsg (bool *stop) |
virtual void | processMsg (Msg *msg) |
virtual void | respondToHeartBeat () |
virtual void | installTimer (Msg *msg) |
virtual void | installSignal (Msg *msg) |
virtual void | enableTimer (Msg *msg) |
virtual void | addHandler (Msg *msg) |
void | stepCommands () |
Protected Attributes | |
Thread * | thread_ |
std::vector< Thread * > | threads_ |
PipeQ< Msg > | msgq_ |
gcp::util::FdSet | fdSet_ |
std::vector< Command * > | commands_ |
struct timeval * | timeOut_ |
TimeVal | commandTimeOut_ |
All tasks will have the following functionality:
|
protected |
Protected constructor ensures that the base class cannot be instantiated.
Constructor
|
protected |
Constructor which initializes thread_, below.
Constructor
|
protectedvirtual |
Making the destructor virtual ensures that the right destructor will be called for classes which inherit from GenericTask.
Destructor
|
protectedvirtual |
Respond to a message to add/remove a handler
Send a message to the signal thread to add a handler.
Reimplemented in gcp::util::GenericMasterTask< Msg >, gcp::util::GenericMasterTask< MasterMsg >, and gcp::util::GenericMasterTask< AntennaMasterMsg >.
|
protected |
Cancel the next thread with the specified order
Method to cancel all threads managed by this task.
This will wait until all spawned threads have shut down, since each call to Thread::cancel() waits on the 'done' condition variable, which is signalled by each thread in its cancellation cleanup handler.
|
protected |
A method to cancel threads managed by this task.
Method to cancel all threads managed by this task.
This will wait until all spawned threads have shut down, since each call to Thread::cancel() waits on the 'done' condition variable, which is signalled by each thread in its cancellation cleanup handler.
|
protectedvirtual |
Respond to a message to enable/disable a timer.
Send a message to the master thread to install a timer.
Reimplemented in gcp::util::GenericMasterTask< Msg >, gcp::util::GenericMasterTask< MasterMsg >, and gcp::util::GenericMasterTask< AntennaMasterMsg >.
|
virtual |
Forward a message to this task via its message queue.
A public method to forward messages to this task via its message queue. We make this virtual so that inheriting tasks can control precisely how messages from the outside world are routed.
protected method sendTaskMsg() (below) is available to inheritors to send messages to themselves.
msg | Pointer to the message to be sent to this task. |
A task-independent method for forwarding a message to a task via its message queue.
|
protected |
Method to return the minimum cancel order for threads which are not yet running.
Method to return the minimum stop order for threads which are still running.
|
protected |
Method to return the minimum start order for threads which are not yet running.
|
protected |
A method to start all threads managed by this task running.
Return a pointer to the thread of this name
Returns: The requested pointer, or NULL on error
|
protectedvirtual |
Respond to a message to install a signal.
Reimplemented in gcp::util::GenericMasterTask< Msg >, gcp::util::GenericMasterTask< MasterMsg >, and gcp::util::GenericMasterTask< AntennaMasterMsg >.
|
protectedvirtual |
Respond to a message to install a timer.
Reimplemented in gcp::util::GenericMasterTask< Msg >, gcp::util::GenericMasterTask< MasterMsg >, and gcp::util::GenericMasterTask< AntennaMasterMsg >.
|
protected |
A method to ping all pingable threads managed by this task.
arg | The argument to be passed to the ping function specified in the Thread constructor. |
Method to ping all threads managed by this task.
|
protectedvirtual |
This method should be defined by each inheriting task to process its own task-specific messages.
Exception | Method to process a message received on the Task message * queue |
Reimplemented in gcp::util::GpibUsbController, gcp::util::DliPowerStripController, gcp::receiver::XMLConsumer, gcp::util::SpawnableTask< Msg >, gcp::util::SpawnableTask< ModemPagerMsg >, gcp::util::SpawnableTask< DlpTempSensorsMsg >, gcp::util::SpawnableTask< HorizonsCommunicatorMsg >, gcp::util::SpawnableTask< LabjackMonitorMsg >, gcp::util::SpawnableTask< PeriodicTimerMsg >, gcp::util::SpawnableTask< IersCommunicatorMsg >, gcp::util::SpawnableTask< GpibUsbControllerMsg >, gcp::util::SpawnableTask< LnaBiasMonitorMsg >, gcp::util::SpawnableTask< TestMsg >, gcp::util::SpawnableTask< AdcMonitorMsg >, gcp::util::SpawnableTask< TipperCommunicatorMsg >, gcp::util::SpawnableTask< DliPowerStripControllerMsg >, TestClass, gcp::receiver::BolometerConsumer, and gcp::receiver::DioConsumer.
|
protectedvirtual |
Process a message received on our message queue
Exception | Method to process a message received on the Task message * queue |
Reimplemented in gcp::util::GenericMasterTask< Msg >, gcp::util::GenericMasterTask< MasterMsg >, and gcp::util::GenericMasterTask< AntennaMasterMsg >.
|
protected |
Raise a signal to a named thread.
|
protectedvirtual |
Respond to a heartbeat message.
Exception | Each thread should respond to a heartbeat request by re-setting its running state to true |
|
protectedvirtual |
Restart this thread.
Restart method stub
|
protectedvirtual |
Force inheritors to define a run method.
Run method defaults to calling the serviceMsgQ() method below.
Reimplemented in gcp::mediator::ReceiverControl, gcp::util::SignalTask, gcp::util::SpawnableTask< Msg >, gcp::util::SpawnableTask< ModemPagerMsg >, gcp::util::SpawnableTask< DlpTempSensorsMsg >, gcp::util::SpawnableTask< HorizonsCommunicatorMsg >, gcp::util::SpawnableTask< LabjackMonitorMsg >, gcp::util::SpawnableTask< PeriodicTimerMsg >, gcp::util::SpawnableTask< IersCommunicatorMsg >, gcp::util::SpawnableTask< GpibUsbControllerMsg >, gcp::util::SpawnableTask< LnaBiasMonitorMsg >, gcp::util::SpawnableTask< TestMsg >, gcp::util::SpawnableTask< AdcMonitorMsg >, gcp::util::SpawnableTask< TipperCommunicatorMsg >, gcp::util::SpawnableTask< DliPowerStripControllerMsg >, and gcp::mediator::AntennaConsumerNotification.
void gcp::util::GenericTask< Msg >::sendHeartBeatMsg | ( | ) |
Method to send a heartbeat message to this task via its message queue.
Send a heartbeat request to this task.
void gcp::util::GenericTask< Msg >::sendRestartMsg | ( | ) |
Method to send a stop message to this task via its message queue.
Send a restart request to this thread
void gcp::util::GenericTask< Msg >::sendStopMsg | ( | ) |
Method to send a stop message to this task via its message queue.
Send a shutdown request to this thread
|
protected |
Send a message to this task via its message queue.
msg | Pointer to the message to be sent to this task. |
A task-independent method for sending a message to a task via its message queue
|
protectedvirtual |
This routine will simply block, servicing messages on the message queue. This is declared virtual so that inheritors can overload with their own methods.
Exception | Main Task event loop: when this is called, the task blocks forever in select(), or until a stop message is received. yes |
Exception | (also via msgq_.rfds()) |
Reimplemented in gcp::util::GpibUsbController, gcp::receiver::ReceiverConfigConsumer, gcp::util::SignalTask, and gcp::receiver::DioConsumer.
|
protected |
Shutdown a connection. This method calls shutdown() and close() on the file descriptor, and clears it from the set of desfcriptors to be watched by this task.
Shutdown a connection.
|
protected |
Start the next thread with the specified order
Method to start the next thread with a given start priority
|
protected |
A method to start all threads. This calls the run() method of all Threads managed by this task, which calls pthread_create() for each thread.
arg | The argument to be passed to the thread startup function specified in the Thread constructor. |
Method to start the next thread with a given start priority
|
protected |
....................................................................... Step through any commands we are running
|
protected |
A method to test if the threads managed by this task are running.
|
protected |
Return true if there are still uncancelled threads
Return true if there are still running threads
|
protected |
Return true if there are still unstarted threads
|
protected |
A set of file descriptors associated with this task.
|
protected |
A message queue, implemented as a pipe, by which we can communicate with this task.
|
protected |
If this GenericTask object was instantiated by another thread, keep a pointer to it here. If non-NULL, this will be used to broadcast to other threads that this task is shutting down (see ~GenericTask(), below).
|
protected |
A vector of Thread objects managed by this task.