NAME
ACE_Task_Exit -
Keep exit information for a Task in thread specific storage so
that the Task::close() method will get called no matter how
the thread exits (e.g., via Thread::exit() or by "falling off
the end of Task::svc_run").
SYNOPSIS
#include <ace/Task.h>
template<ACE_SYNCH_1>
class ACE_Task_Exit
{
public:
ACE_Task_Exit (void);
void set_this (ACE_Task<ACE_SYNCH_2> *t);
void *status (void *s);
void *status (void);
~ACE_Task_Exit (void);
static ACE_Task_Exit<ACE_SYNCH_2> *instance (void);
private:
ACE_Task<ACE_SYNCH_2> *t_;
void *status_;
ACE_Thread_Control tc_;
static ACE_Thread_Mutex ace_task_lock_;
};
DESCRIPTION
This clever little helper class is stored in thread-specific
storage using the ACE_TSS wrapper. When a thread
exits the ACE_TSS::cleanup() function calls
"delete" on this object, thereby closing it down gracefully.
PUBLIC MEMBERS
ACE_Task_Exit (void);
Capture the Task object that will be cleaned up automatically.
void set_this (ACE_Task<ACE_SYNCH_2> *t);
void *status (void *s);
void *status (void);
~ACE_Task_Exit (void);
Destructor calls the close method of the captured Task on exit.
static ACE_Task_Exit<ACE_SYNCH_2> *instance (void);
PRIVATE MEMBERS
ACE_Task<ACE_SYNCH_2> *t_;
Pointer to the captured Task.
void *status_;
ACE_Thread_Control tc_;
This is used to make sure that an ACE_Task registers and
deregisters with the ACE_Thread_Manager correctly.
static ACE_Thread_Mutex ace_task_lock_;
Lock the creation of the Singleton.
AUTHOR
Doug Schmidt
LIBRARY
ace