ACE
6.3.1
|
Direct base class for the ACE_Task template. More...
#include <Task.h>
Public Member Functions | |
ACE_Task_Base (ACE_Thread_Manager *=0) | |
Constructor. More... | |
virtual | ~ACE_Task_Base (void) |
Destructor. More... | |
virtual int | open (void *args=0) |
Default ACE_Task open routine. More... | |
virtual int | close (u_long flags=0) |
Default ACE_Task close routine. More... | |
virtual int | module_closed (void) |
virtual int | put (ACE_Message_Block *, ACE_Time_Value *=0) |
Default ACE_Task put routine. More... | |
virtual int | svc (void) |
Run by a daemon thread to handle deferred processing. More... | |
virtual int | activate (long flags=THR_NEW_LWP|THR_JOINABLE|THR_INHERIT_SCHED, int n_threads=1, int force_active=0, long priority=ACE_DEFAULT_THREAD_PRIORITY, int grp_id=-1, ACE_Task_Base *task=0, ACE_hthread_t thread_handles[]=0, void *stack[]=0, size_t stack_size[]=0, ACE_thread_t thread_ids[]=0, const char *thr_name[]=0) |
virtual int | wait (void) |
Wait for all threads running in a task to exit. More... | |
virtual int | suspend (void) |
Suspend a task. More... | |
virtual int | resume (void) |
Resume a suspended task. More... | |
int | grp_id (void) const |
Get the current group id. More... | |
void | grp_id (int) |
Set the current group id. More... | |
ACE_Thread_Manager * | thr_mgr (void) const |
Get the thread manager associated with this Task. More... | |
void | thr_mgr (ACE_Thread_Manager *) |
Set the thread manager associated with this Task. More... | |
int | is_reader (void) const |
True if queue is a reader, else false. More... | |
int | is_writer (void) const |
True if queue is a writer, else false. More... | |
size_t | thr_count (void) const |
ACE_thread_t | last_thread (void) const |
![]() | |
ACE_Service_Object (ACE_Reactor *=0) | |
Constructor. More... | |
virtual | ~ACE_Service_Object (void) |
Destructor. More... | |
![]() | |
virtual | ~ACE_Event_Handler (void) |
Destructor is virtual to enable proper cleanup. More... | |
virtual ACE_HANDLE | get_handle (void) const |
Get the I/O handle. More... | |
virtual void | set_handle (ACE_HANDLE) |
Set the I/O handle. More... | |
virtual int | priority (void) const |
virtual void | priority (int priority) |
Set the priority of the Event_Handler. More... | |
virtual int | handle_input (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
Called when input events occur (e.g., connection or data). More... | |
virtual int | handle_output (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
virtual int | handle_exception (ACE_HANDLE fd=ACE_INVALID_HANDLE) |
Called when an exceptional events occur (e.g., SIGURG). More... | |
virtual int | handle_timeout (const ACE_Time_Value ¤t_time, const void *act=0) |
virtual int | handle_exit (ACE_Process *) |
Called when a process exits. More... | |
virtual int | handle_close (ACE_HANDLE handle, ACE_Reactor_Mask close_mask) |
virtual int | handle_signal (int signum, siginfo_t *=0, ucontext_t *=0) |
virtual int | resume_handler (void) |
virtual int | handle_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
virtual int | handle_group_qos (ACE_HANDLE=ACE_INVALID_HANDLE) |
virtual void | reactor (ACE_Reactor *reactor) |
Set the event demultiplexors. More... | |
virtual ACE_Reactor * | reactor (void) const |
Get the event demultiplexors. More... | |
virtual ACE_Reactor_Timer_Interface * | reactor_timer_interface (void) const |
Get only the reactor's timer related interface. More... | |
virtual Reference_Count | add_reference (void) |
Increment reference count on the handler. More... | |
virtual Reference_Count | remove_reference (void) |
Decrement reference count on the handler. More... | |
Reference_Counting_Policy & | reference_counting_policy (void) |
Current Reference_Counting_Policy. More... | |
![]() | |
ACE_Shared_Object (void) | |
Constructor. More... | |
virtual | ~ACE_Shared_Object (void) |
Destructor. More... | |
virtual int | init (int argc, ACE_TCHAR *argv[]) |
Initializes object when dynamic linking occurs. More... | |
virtual int | fini (void) |
Terminates object when dynamic unlinking occurs. More... | |
virtual int | info (ACE_TCHAR **info_string, size_t length=0) const |
Returns information on a service object. More... | |
Static Public Member Functions | |
static ACE_THR_FUNC_RETURN | svc_run (void *) |
Routine that runs the service routine as a daemon thread. More... | |
static void | cleanup (void *object, void *params) |
![]() | |
static ACE_THR_FUNC_RETURN | read_adapter (void *event_handler) |
static int | register_stdin_handler (ACE_Event_Handler *eh, ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr, int flags=THR_DETACHED) |
static int | remove_stdin_handler (ACE_Reactor *reactor, ACE_Thread_Manager *thr_mgr) |
Performs the inverse of the register_stdin_handler() method. More... | |
Protected Attributes | |
size_t | thr_count_ |
ACE_Thread_Manager * | thr_mgr_ |
Multi-threading manager. More... | |
u_long | flags_ |
ACE_Task flags. More... | |
int | grp_id_ |
This maintains the group id of the Task. More... | |
ACE_thread_t | last_thread_id_ |
Holds the thread ID of the last thread to exit svc() in this object. More... | |
![]() | |
Atomic_Reference_Count | reference_count_ |
Reference count. More... | |
Private Member Functions | |
ACE_Task_Base & | operator= (const ACE_Task_Base &) |
ACE_Task_Base (const ACE_Task_Base &) | |
Additional Inherited Members | |
![]() | |
enum | { LO_PRIORITY = 0, HI_PRIORITY = 10, NULL_MASK = 0, READ_MASK = (1 << 0), WRITE_MASK = (1 << 1), EXCEPT_MASK = (1 << 2), ACCEPT_MASK = (1 << 3), CONNECT_MASK = (1 << 4), TIMER_MASK = (1 << 5), QOS_MASK = (1 << 6), GROUP_QOS_MASK = (1 << 7), SIGNAL_MASK = (1 << 8), ALL_EVENTS_MASK, RWE_MASK, DONT_CALL = (1 << 9) } |
enum | { ACE_EVENT_HANDLER_NOT_RESUMED = -1, ACE_REACTOR_RESUMES_HANDLER = 0, ACE_APPLICATION_RESUMES_HANDLER } |
typedef long | Reference_Count |
Reference count type. More... | |
![]() | |
typedef ACE_Atomic_Op < ACE_SYNCH_MUTEX, Reference_Count > | Atomic_Reference_Count |
Typedef for implementation of reference counting. More... | |
![]() | |
ACE_Event_Handler (ACE_Reactor *=0, int priority=ACE_Event_Handler::LO_PRIORITY) | |
Force ACE_Event_Handler to be an abstract base class. More... | |
Direct base class for the ACE_Task template.
This class factors out the non-template code in order to reduce template bloat, as well as to make it possible for the ACE_Thread_Manager to store ACE_Task_Base *'s polymorphically.
ACE_Task_Base::ACE_Task_Base | ( | ACE_Thread_Manager * | thr_man = 0 | ) |
Constructor.
|
virtual |
Destructor.
|
private |
|
virtual |
Turn the task into an active object, i.e., having n_threads of control, all running at the priority level (see below) with the same grp_id, all of which invoke <Task::svc>. Returns -1 if failure occurs, returns 1 if Task is already an active object and force_active is false (i.e., do not create a new thread in this case), and returns 0 if Task was not already an active object and a thread is created successfully or thread is an active object and force_active is true. Note that if force_active is true and there are already threads spawned in this <Task>, the grp_id parameter is ignored and the grp_id of any newly activated thread(s) will inherit the existing grp_id of the existing thread(s) in the <Task>.
The <{flags}> are a bitwise-OR of the following: = BEGIN<INDENT> THR_CANCEL_DISABLE, THR_CANCEL_ENABLE, THR_CANCEL_DEFERRED, THR_CANCEL_ASYNCHRONOUS, THR_BOUND, THR_NEW_LWP, THR_DETACHED, THR_SUSPENDED, THR_DAEMON, THR_JOINABLE, THR_SCHED_FIFO, THR_SCHED_RR, THR_SCHED_DEFAULT, THR_EXPLICIT_SCHED, THR_SCOPE_SYSTEM, THR_SCOPE_PROCESS = END<INDENT> If THR_SCHED_INHERIT is not desirable, applications should specifically pass in THR_EXPLICIT_SCHED.
By default, or if <{priority}> is set to ACE_DEFAULT_THREAD_PRIORITY, an "appropriate" priority value for the given scheduling policy (specified in <{flags}>, e.g., <THR_SCHED_DEFAULT>) is used. This value is calculated dynamically, and is the median value between the minimum and maximum priority values for the given policy. If an explicit value is given, it is used. Note that actual priority values are EXTREMEMLY implementation-dependent, and are probably best avoided.
If thread_handles != 0 it is assumed to be an array of n thread_handles that will be assigned the values of the thread handles being spawned. Returns -1 on failure (errno
will explain...), otherwise returns the group id of the threads.
Assigning task allows you to associate the newly spawned threads with an instance of ACE_Task_Base. If task == 0, then the new threads are associated automatically with this
ACE_Task_Base. Setting the task argument to value other than this
makes the thread manipulating methods, such as wait(), suspend(), resume(), useless. Threads spawned with user specified task value must therefore be manipulated thru ACE_Thread_Manager directly.
If stack != 0 it is assumed to be an array of n pointers to the base of the stacks to use for the threads being spawned. Likewise, if stack_size != 0 it is assumed to be an array of n values indicating how big each of the corresponding stacks are.
Reimplemented in ACE_Thread_Timer_Queue_Adapter< TQ, TYPE >.
|
static |
Cleanup hook that is called when a thread exits to gracefully shutdown an ACE_Task.
|
virtual |
Default ACE_Task close routine.
Hook called from ACE_Thread_Exit when during thread exit and from the default implementation of module_closed()
. In general, this method shouldn't be called directly by an application, particularly if the Task is running as an Active Object. Instead, a special message should be passed into the Task via the put() method defined below, and the svc() method should interpret this as a flag to shut down the Task.
Reimplemented in ACE_Svc_Handler< PEER_STREAM, SYNCH_TRAITS >.
|
inline |
Get the current group id.
|
inline |
Set the current group id.
|
inline |
True if queue is a reader, else false.
|
inline |
True if queue is a writer, else false.
|
inline |
Returns the thread ID of the thread whose exit caused this object's thread count to be decremented to 0.
When a thread spawned in the context of this object (using activate()) returns from its svc() method ACE calls the close() hook. Before it does so, it decrements the number of active threads. If the number of threads is decremented to 0, the thread ID of the current thread is stored for access by this method. If the returned thread ID matches the calling thread's ID, the calling thread knows that there are no other threads still active in the ACE_Task.
ACE_thread_t | of the last thread to close. 0 if the last thread is not yet known; for example, if no threads are active, or if multiple threads are active. |
|
virtual |
Hook called during ACE_Module::close(). The default implementation calls forwards the call to close(1). Please notice the changed value of the default argument of close(). This allows tasks to differ between the call has been originated from ACE_Thread_Exit or from module_closed(). Be aware that close(0) will be also called when a thread associated with the ACE_Task instance exits.
Forward the call to close() so that existing applications don't break.
|
virtual |
Default ACE_Task open routine.
Hook called to initialize a task and prepare it for execution. args can be used to pass arbitrary information into <open>.
Reimplemented in ACE_NT_Service, and ACE_Svc_Handler< PEER_STREAM, SYNCH_TRAITS >.
|
private |
|
virtual |
Default ACE_Task put routine.
A hook method that can be used to pass a message to a task, where it can be processed immediately or queued for subsequent processing in the svc() hook method.
Reimplemented in ACE_Buffered_Svc_Handler< PEER_STREAM, SYNCH_TRAITS >.
|
virtual |
Resume a suspended task.
Reimplemented from ACE_Service_Object.
|
virtual |
Suspend a task.
Reimplemented from ACE_Service_Object.
|
virtual |
Run by a daemon thread to handle deferred processing.
Default ACE_Task service routine.
Reimplemented in ACE_Thread_Timer_Queue_Adapter< TQ, TYPE >, ACE_NT_Service, ACE_Proactor_Timer_Handler, and ACE_Asynch_Pseudo_Task.
|
static |
Routine that runs the service routine as a daemon thread.
|
inline |
Returns the number of threads currently running within a task. If we're a passive object this value is 0, else it's greater than 0.
|
inline |
Get the thread manager associated with this Task.
|
inline |
Set the thread manager associated with this Task.
|
virtual |
Wait for all threads running in a task to exit.
Block until there are no more threads running in this task. This method will not wait for either detached or daemon threads; the threads must have been spawned with the THR_JOINABLE
flag. Upon successful completion, the threads have been joined, so further attempts to join with any of the waited-for threads will fail.
0 | Success. |
-1 | Failure (consult errno for further information). |
|
protected |
ACE_Task flags.
|
protected |
This maintains the group id of the Task.
|
protected |
Holds the thread ID of the last thread to exit svc() in this object.
|
protected |
Count of the number of threads running within the task. If this value is greater than 0 then we're an active object and the value of <thr_count_> is the number of active threads at this instant. If the value == 0, then we're a passive object.
|
protected |
Multi-threading manager.