ACS::Thread − |
#include <acsThread.h> Inherits ACS::ThreadBase. Inherited by acsalarm::AlarmSourceThread, AcsBulkdata::BulkDataNTArrayThread, AcsBulkdata::StreamerThread, ControllerThread, DoorThread, FridgeThread, PositionControlThread, PositionControlThread, RequestProcessorThread, SamplingThread< ACS_SAMP_C >, SamplingThread< ACS_SAMP_TL >, SamplingThreadFlush< ACS_SAMP_C >, SamplingThreadFlush< ACS_SAMP_TL >, SenderThread, and TestACSThread. |
Public Member Functions |
Thread (const ACE_CString &name, const TimeInterval &responseTime=ThreadBase::defaultResponseTime, const TimeInterval &sleepTime=ThreadBase::defaultSleepTime, const bool del=false, const long _thrFlags=THR_NEW_LWP|THR_DETACHED, const size_t stackSize=ACE_DEFAULT_THREAD_STACKSIZE) |
virtual ~Thread () |
virtual void onStart () |
virtual void onStop () |
virtual void commonStart () |
virtual void commonStop () |
virtual void run () |
virtual void runLoop () |
Protected Member Functions |
ACS::ThreadManager * getThreadManager () const |
Static Protected Member Functions |
static void threadSvc (void *param) |
Protected Attributes |
LoggingProxy * logger_mp |
ponter to Logging proxy |
ACS::ThreadManager * thrMgr_mp |
Pointer to thread manager. |
Private Member Functions |
void operator= (const Thread &) |
Thread (const Thread &) |
Private Attributes |
bool delete_m |
Friends |
class ThreadManager |
Thread class is a base class for the ACS based threads. If a user wants to define his/her own thread, it has to create a class which derives from ACS::hread class and the override run or runLoop methods. The Thread class is ment to be used with the support of a ThreaManager. It is possible to use it without a ThreadManager, but you have to be careful and read accurately this documentation to be aware of things you have to be careful with. |
ACS::Thread::Thread (const ACE_CString & name, const TimeInterval & responseTime = ThreadBase::defaultResponseTime, const TimeInterval & sleepTime = ThreadBase::defaultSleepTime, const bool del = false, const long _thrFlags = THR_NEW_LWP|THR_DETACHED, const size_t stackSize = ACE_DEFAULT_THREAD_STACKSIZE) Constructor of the Thread class. If someone wants to set thread parameters, s/he has to send these parameters from the constructor of the derived class up to the base class. |
Exceptions: |
acsthreadErrType::CanNotSpawnThreadExImpl |
Parameters: |
name thread’s name |
Attention: |
This means that the thread will call ’delete
this’ after the thread function execution is
completed. all of thread will be suspended. |
• |
creates the Thread object suspended |
||
• |
if was to be not-suspended calls release() after construction |
autodelete threads are created as non joinable, but all other threads are created joinable and the developer has to take care of joining them, otherwise resourses will be lost and it will be possible to allocate only a few hundred tests before crashing the machine |
2006/07/06 merge two constructor, since there is almost
no difference between them |
_stackSize The size of the stack of the thread. If ACE_DEFAULT_THREAD_STACKSIZE the default ACE stack size is taken. |
virtual ACS::Thread::~Thread () [virtual] Thread destructor. |
ACS::Thread::Thread (const Thread &) [private] ALMA C++ coding standards state copy constructors should be disabled. |
virtual void ACS::Thread::commonStart () [virtual] This method performs basic thread initialization, common to all threads. It is called by threadSvc and call the user hook onStart. The common initialization performs the initialization of the logging system, which has to be done on a per thread base. It shall not be overridden unless it is really necessary (for example. user does not like what is done for common initialization). In most cases if should be sufficient to override of onStart. |
virtual void ACS::Thread::commonStop () [virtual] This method performs basic thread cleanup, common to all threads. It is called by threadSvc and call the user hook onStop. The common cleanup performs the cleanup of the logging system, which has to be done on a per thread base. It shall not be overridden unless it is really necessary (for example. user does not like what is done for common cleanup). In most cases if should be sufficient to override of onStop. |
ACS::ThreadManager* ACS::Thread::getThreadManager () const [protected] Returns pointer to the thread manager responsible for this thread. |
virtual void ACS::Thread::onStart () [inline, virtual] Method which is executed before the body of the thread. It is the hook method for a user that wants to do some initialization before the thread execution (thread initialization), s/he has to override/implement this method in the implementation class. It is called by commonStart |
Reimplemented in RequestProcessorThread, ControllerThread, and DoorThread. |
virtual void ACS::Thread::onStop () [inline, virtual] Method which is executed after the body of the thread, i.e. after the thread execution. It is the hook method for a user that wants to do some cleanup after the thread execution (thread cleanup), s/he has to override/implement this method in the implementation class. It is called by commonStop |
Reimplemented in DoorThread. |
void ACS::Thread::operator= (const Thread &) [private] ALMA C++ coding standards state assignment operators should be disabled. |
virtual void ACS::Thread::run () [virtual] Basic used hook to implement the thread functionality. The provided default implementation executes the method runLoop in a loop, to provide periodic loops. If a user wants that his/her thread function is executed periodically, s/he has to override the runLoop. Between two iterations the runLoop sleeps for responseTime 100ns If a user wants that his/her thread function is executed only once, s/he has to override this method. |
Reimplemented in SenderThread, AcsBulkdata::BulkDataNTArrayThread, and AcsBulkdata::StreamerThread. |
virtual void ACS::Thread::runLoop () [inline, virtual] Basic used hook to implement the thread functionality in a periodic loop. The method is executed in a loop until the thread is alive and every responseTime 100ns by the run method. The thread can be exited from the lop by calling ACS::ThreadBase::stop or ACS::ThreadBase::exit command. If the run method is overridden than runLoop is not executed. |
Reimplemented in acsalarm::AlarmSourceThread, PositionControlThread, PositionControlThread, RequestProcessorThread, ControllerThread, DoorThread, FridgeThread, SamplingThread< ACS_SAMP_C >, SamplingThreadFlush< ACS_SAMP_C >, TestACSThread, SamplingThread< ACS_SAMP_TL >, and SamplingThreadFlush< ACS_SAMP_TL >. |
static void ACS::Thread::threadSvc (void * param) [static, protected] Static method which is passed to the ACE thread manager which than spawns the thread. This is the actual thread service function. It executes: |
• |
commonStart() (which by default implementation executes onStart()), |
||
• |
run() (which by default implementation executes runLoop()), |
||
• |
commonStop() (which by default implementation executes onStop()). |
friend class ThreadManager [friend] |
bool ACS::Thread::delete_m [private] flag that indicates if thread should be deleted after the thread exits |
LoggingProxy* ACS::Thread::logger_mp [protected] |
ponter to Logging proxy |
ACS::ThreadManager* ACS::Thread::thrMgr_mp [protected] |
Pointer to thread manager. |
Generated automatically by Doxygen for ACS-2015.2 C++ API from the source code. |