CARMA C++
sza::util::SpawnableTask< Msg > Class Template Reference

...................................................................... More...

#include <carma/szautil/SpawnableTask.h>

Inheritance diagram for sza::util::SpawnableTask< Msg >:
sza::util::GenericTask< Msg >

Public Member Functions

void run ()
 Force inheritors to define a run method. More...
 
 SpawnableTask (bool spawn)
 Constructor. More...
 
virtual ~SpawnableTask ()
 Destructor. More...
 
- Public Member Functions inherited from sza::util::GenericTask< Msg >
virtual void fwdTaskMsg (Msg *msg)
 Forward a message to this task via its message queue. More...
 
void sendHeartBeatMsg ()
 Method to send a heartbeat message to this task via its message queue. More...
 
void sendRestartMsg ()
 Method to send a stop message to this task via its message queue. More...
 
void sendStopMsg ()
 Method to send a stop message to this task via its message queue. More...
 
- Public Member Functions inherited from sza::util::RunnableTask
virtual void run ()
 
 RunnableTask (bool spawnThread)
 Constructor. More...
 
virtual ~RunnableTask ()
 Destructor. More...
 
- Public Member Functions inherited from sza::util::Runnable
 Runnable (bool spawnThread, void *(*runFn)(void *arg))
 Constructor. More...
 
virtual void spawn ()
 
virtual ~Runnable ()
 Destructor. More...
 

Protected Member Functions

virtual void processMsg (Msg *msg)
 This method should be defined by each inheriting task to process its own task-specific messages. More...
 
- Protected Member Functions inherited from sza::util::GenericTask< Msg >
virtual void addHandler (Msg *msg)
 Respond to a message to add/remove a handler. More...
 
void cancelThread (unsigned order)
 Cancel the next thread with the specified order. More...
 
void cancelThreads ()
 A method to cancel threads managed by this task. More...
 
virtual void enableTimer (Msg *msg)
 Respond to a message to enable/disable a timer. More...
 
 GenericTask ()
 Protected constructor ensures that the base class cannot be instantiated. More...
 
 GenericTask (Thread *thread)
 Constructor which initializes thread_, below. More...
 
unsigned getMinCancelOrder ()
 Method to return the minimum cancel order for threads which are not yet running. More...
 
unsigned getMinStartOrder ()
 Method to return the minimum start order for threads which are not yet running. More...
 
ThreadgetThread (std::string name)
 A method to start all threads managed by this task running. More...
 
virtual void installSignal (Msg *msg)
 Respond to a message to install a signal. More...
 
virtual void installTimer (Msg *msg)
 Respond to a message to install a timer. More...
 
void pingThreads (void *arg)
 A method to ping all pingable threads managed by this task. More...
 
virtual void processTaskMsg (bool *stop)
 Process a message received on our message queue. More...
 
void raise (std::string name, int sigNo)
 Raise a signal to a named thread. More...
 
virtual void respondToHeartBeat ()
 Respond to a heartbeat message. More...
 
virtual void restart (void)
 Restart this thread. More...
 
void sendTaskMsg (Msg *msg)
 Send a message to this task via its message queue. More...
 
virtual void serviceMsgQ (void)
 This routine will simply block, servicing messages on the message queue. More...
 
void shutdownConnection (int fd)
 Shutdown a connection. More...
 
void startThread (void *arg, unsigned order)
 Start the next thread with the specified order. More...
 
void startThreads (void *arg)
 A method to start all threads. More...
 
bool threadsAreRunning ()
 A method to test if the threads managed by this task are running. More...
 
bool threadsNeedCancelling ()
 Return true if there are still uncancelled threads. More...
 
bool threadsNeedStarting ()
 Return true if there are still unstarted threads. More...
 
virtual ~GenericTask ()
 Making the destructor virtual ensures that the right destructor will be called for classes which inherit from GenericTask. More...
 
- Protected Member Functions inherited from sza::util::Runnable
void spawn (void *arg)
 

Additional Inherited Members

- Static Public Member Functions inherited from sza::util::RunnableTask
static RUN_FN (runFn)
 A run method to be called from pthread_start() More...
 
- Static Public Member Functions inherited from sza::util::Runnable
static void blockForever ()
 
static THREAD_START (startUp)
 A startup function for the spawned thread. More...
 
- Protected Attributes inherited from sza::util::GenericTask< Msg >
sza::util::FdSet fdSet_
 A set of file descriptors associated with this task. More...
 
PipeQ< Msg > msgq_
 A message queue, implemented as a pipe, by which we can communicate with this task. More...
 
Threadthread_
 If this GenericTask object was instantiated by another thread, keep a pointer to it here. More...
 
std::vector< Thread * > threads_
 A vector of Thread objects managed by this task. More...
 
- Protected Attributes inherited from sza::util::Runnable
void *(* runFn_ )(void *arg)
 
bool spawned_
 True if this object is spawned in a separate thread. More...
 
ThreadspawnedThread_
 If this object is spawned in its own thread, we will use a Thread container to manage it. More...
 

Detailed Description

template<class Msg>
class sza::util::SpawnableTask< Msg >

......................................................................

Define a template class for an object which can run in its own thread. This inherits the message queue mechanism from GenericTask for communciation with this thread, and spawnable capabilities from Runnable

Definition at line 34 of file SpawnableTask.h.

Constructor & Destructor Documentation

template<class Msg>
sza::util::SpawnableTask< Msg >::SpawnableTask ( bool  spawn)

Constructor.

If spawn==true, then a call to spawn() will start this thread

Definition at line 43 of file SpawnableTask.h.

template<class Msg>
virtual sza::util::SpawnableTask< Msg >::~SpawnableTask ( )
virtual

Destructor.

Definition at line 48 of file SpawnableTask.h.

Member Function Documentation

template<class Msg>
virtual void sza::util::SpawnableTask< Msg >::processMsg ( Msg *  msg)
protectedvirtual

This method should be defined by each inheriting task to process its own task-specific messages.

Method to process a message received on the Task message * queue.

Exceptions
Exception

Reimplemented from sza::util::GenericTask< Msg >.

Definition at line 57 of file SpawnableTask.h.

template<class Msg>
void sza::util::SpawnableTask< Msg >::run ( void  )
virtual

Force inheritors to define a run method.

Run method defaults to calling the serviceMsgQ() method below.

Reimplemented from sza::util::GenericTask< Msg >.

Definition at line 61 of file SpawnableTask.h.


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