File: ACE_Task_Base.3

package info (click to toggle)
ace 5.2.1-1
  • links: PTS
  • area: main
  • in suites: woody
  • size: 26,856 kB
  • ctags: 18,677
  • sloc: cpp: 171,831; makefile: 48,840; sh: 10,192; perl: 8,582; exp: 787; yacc: 387; lex: 140; csh: 20
file content (265 lines) | stat: -rw-r--r-- 10,837 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
.TH ACE_Task_Base 3 "1 Dec 2001" "ACE" \" -*- nroff -*-
.ad l
.nh
.SH NAME
ACE_Task_Base \- Direct base class for the \fBACE_Task\fR template. 
.SH SYNOPSIS
.br
.PP
\fC#include <Task.h>\fR
.PP
Inherits \fBACE_Service_Object\fR.
.PP
Inherited by \fBACE_Task\fR, and \fBACE_Thread_Timer_Queue_Adapter\fR.
.PP
.SS Public Methods

.in +1c
.ti -1c
.RI "\fBACE_Task_Base\fR (\fBACE_Thread_Manager\fR * = 0)"
.br
.RI "\fIConstructor.\fR"
.ti -1c
.RI "virtual \fB~ACE_Task_Base\fR (void)"
.br
.RI "\fIDestructor.\fR"
.ti -1c
.RI "virtual int \fBopen\fR (void *args = 0)"
.br
.RI "\fIHook called to open a Task.  can be used to pass arbitrary information into <open>.\fR"
.ti -1c
.RI "virtual int \fBclose\fR (u_long flags = 0)"
.br
.ti -1c
.RI "virtual int \fBmodule_closed\fR (void)"
.br
.ti -1c
.RI "virtual int \fBput\fR (\fBACE_Message_Block\fR *, \fBACE_Time_Value\fR * = 0)"
.br
.RI "\fIA 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.\fR"
.ti -1c
.RI "virtual int \fBsvc\fR (void)"
.br
.RI "\fIRun by a daemon thread to handle deferred processing.\fR"
.ti -1c
.RI "virtual int \fBactivate\fR (long flags = THR_NEW_LWP | THR_JOINABLE, int n_threads = 1, int force_active = 0, long priority = ACE_DEFAULT_THREAD_PRIORITY, int grp_id = -1, ACE_Task_Base *task = 0, \fBACE_hthread_t\fR thread_handles[] = 0, void *stack[] = 0, size_t stack_size[] = 0, \fBACE_thread_t\fR thread_ids[] = 0)"
.br
.ti -1c
.RI "virtual int \fBwait\fR (void)"
.br
.RI "\fIWait for all threads running in this task to exit.\fR"
.ti -1c
.RI "virtual int \fBsuspend\fR (void)"
.br
.RI "\fISuspend a task. Resume a suspended task.\fR"
.ti -1c
.RI "virtual int \fBresume\fR (void)"
.br
.RI "\fIRe-enable a previously suspended service.\fR"
.ti -1c
.RI "int \fBgrp_id\fR (void) const"
.br
.RI "\fIGet the current group id.\fR"
.ti -1c
.RI "void \fBgrp_id\fR (int)"
.br
.RI "\fISet the current group id.\fR"
.ti -1c
.RI "\fBACE_Thread_Manager\fR* \fBthr_mgr\fR (void) const"
.br
.RI "\fIGets the thread manager associated with this Task.\fR"
.ti -1c
.RI "void \fBthr_mgr\fR (\fBACE_Thread_Manager\fR *)"
.br
.RI "\fISet the thread manager associated with this Task.\fR"
.ti -1c
.RI "int \fBis_reader\fR (void) const"
.br
.RI "\fITrue if queue is a reader, else false.\fR"
.ti -1c
.RI "int \fBis_writer\fR (void) const"
.br
.RI "\fITrue if queue is a writer, else false.\fR"
.ti -1c
.RI "size_t \fBthr_count\fR (void) const"
.br
.ti -1c
.RI "void \fBthr_count_dec\fR (void)"
.br
.RI "\fIAtomically decrement the thread count by 1. This should only be called by the  class destructor.\fR"
.in -1c
.SS Public Attributes

.in +1c
.ti -1c
.RI "size_t \fBthr_count_\fR"
.br
.ti -1c
.RI "\fBACE_Thread_Manager\fR* \fBthr_mgr_\fR"
.br
.RI "\fIMulti-threading manager.\fR"
.ti -1c
.RI "u_long \fBflags_\fR"
.br
.RI "\fI\fBACE_Task\fR flags.\fR"
.ti -1c
.RI "int \fBgrp_id_\fR"
.br
.RI "\fIThis maintains the group id of the Task.\fR"
.in -1c
.SS Static Public Methods

.in +1c
.ti -1c
.RI "void* \fBsvc_run\fR (void *)"
.br
.RI "\fIRoutine that runs the service routine as a daemon thread.\fR"
.ti -1c
.RI "void \fBcleanup\fR (void *object, void *params)"
.br
.RI "\fICleanup hook that is called when a thread exits to gracefully shutdown an .\fR"
.in -1c
.SS Private Methods

.in +1c
.ti -1c
.RI "ACE_Task_Base& \fBoperator=\fR (const ACE_Task_Base &)"
.br
.ti -1c
.RI "\fBACE_Task_Base\fR (const ACE_Task_Base &)"
.br
.in -1c
.SH DETAILED DESCRIPTION
.PP 
Direct base class for the \fBACE_Task\fR template.
.PP
.PP
 This class factors out the non-template code in order to reduce template bloat, as well as to make it possible for the  to store  *'s polymorphically. 
.PP
.SH CONSTRUCTOR & DESTRUCTOR DOCUMENTATION
.PP 
.SS ACE_Task_Base::ACE_Task_Base (\fBACE_Thread_Manager\fR * = 0)
.PP
Constructor.
.PP
.SS ACE_Task_Base::~ACE_Task_Base (void)\fC [virtual]\fR
.PP
Destructor.
.PP
.SS ACE_Task_Base::ACE_Task_Base (const ACE_Task_Base &)\fC [private]\fR
.PP
.SH MEMBER FUNCTION DOCUMENTATION
.PP 
.SS int ACE_Task_Base::activate (long flags = THR_NEW_LWP | THR_JOINABLE, int n_threads = 1, int force_active = 0, long priority = ACE_DEFAULT_THREAD_PRIORITY, int grp_id = -1, ACE_Task_Base * task = 0, \fBACE_hthread_t\fR thread_handles[] = 0, void * stack[] = 0, size_t stack_size[] = 0, \fBACE_thread_t\fR thread_names[] = 0)\fC [virtual]\fR
.PP
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>.
.PP
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>
.PP
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.
.PP
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.
.PP
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 <stack>s are. 
.PP
Reimplemented in \fBACE_Thread_Timer_Queue_Adapter\fR.
.SS void ACE_Task_Base::cleanup (void * object, void * params)\fC [static]\fR
.PP
Cleanup hook that is called when a thread exits to gracefully shutdown an .
.PP
.SS int ACE_Task_Base::close (u_long flags = 0)\fC [virtual]\fR
.PP
Hook called from  when during thread exit and from the default implemenation 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>. 
.PP
Reimplemented in \fBACE_Stream_Head\fR, \fBACE_Stream_Tail\fR, \fBACE_Thru_Task\fR, and \fBACE_Svc_Handler\fR.
.SS void ACE_Task_Base::grp_id (int)
.PP
Set the current group id.
.PP
.SS int ACE_Task_Base::grp_id (void) const
.PP
Get the current group id.
.PP
.SS int ACE_Task_Base::is_reader (void) const
.PP
True if queue is a reader, else false.
.PP
.SS int ACE_Task_Base::is_writer (void) const
.PP
True if queue is a writer, else false.
.PP
.SS int ACE_Task_Base::module_closed (void)\fC [virtual]\fR
.PP
Hook called during . 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  or from <module_closed>. Be aware that close(0) will be also called when a thread associated with the \fBACE_Task\fR instance exits. 
.SS int ACE_Task_Base::open (void * a = 0)\fC [virtual]\fR
.PP
Hook called to open a Task.  can be used to pass arbitrary information into <open>.
.PP
Reimplemented in \fBACE_NT_Service\fR, \fBACE_Stream_Head\fR, \fBACE_Stream_Tail\fR, \fBACE_Thru_Task\fR, and \fBACE_Svc_Handler\fR.
.SS ACE_Task_Base& ACE_Task_Base::operator= (const ACE_Task_Base &)\fC [private]\fR
.PP
.SS int ACE_Task_Base::put (\fBACE_Message_Block\fR * msg, \fBACE_Time_Value\fR * timeout = 0)\fC [virtual]\fR
.PP
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.
.PP
Reimplemented in \fBACE_Stream_Head\fR, \fBACE_Stream_Tail\fR, \fBACE_Thru_Task\fR, and \fBACE_Buffered_Svc_Handler\fR.
.SS virtual int ACE_Task_Base::resume (void)\fC [virtual]\fR
.PP
Re-enable a previously suspended service.
.PP
Reimplemented from \fBACE_Service_Object\fR.
.SS int ACE_Task_Base::suspend (void)\fC [virtual]\fR
.PP
Suspend a task. Resume a suspended task.
.PP
Reimplemented from \fBACE_Service_Object\fR.
.SS int ACE_Task_Base::svc (void)\fC [virtual]\fR
.PP
Run by a daemon thread to handle deferred processing.
.PP
Reimplemented in \fBACE_NT_Service\fR, \fBACE_Stream_Head\fR, \fBACE_Stream_Tail\fR, \fBACE_Thru_Task\fR, and \fBACE_Thread_Timer_Queue_Adapter\fR.
.SS void * ACE_Task_Base::svc_run (void *)\fC [static]\fR
.PP
Routine that runs the service routine as a daemon thread.
.PP
.SS size_t ACE_Task_Base::thr_count (void) const
.PP
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. 
.SS void ACE_Task_Base::thr_count_dec (void)
.PP
Atomically decrement the thread count by 1. This should only be called by the  class destructor.
.PP
.SS void ACE_Task_Base::thr_mgr (\fBACE_Thread_Manager\fR *)
.PP
Set the thread manager associated with this Task.
.PP
.SS \fBACE_Thread_Manager\fR * ACE_Task_Base::thr_mgr (void) const
.PP
Gets the thread manager associated with this Task.
.PP
.SS int ACE_Task_Base::wait (void)\fC [virtual]\fR
.PP
Wait for all threads running in this task to exit.
.PP
.SH MEMBER DATA DOCUMENTATION
.PP 
.SS u_long ACE_Task_Base::flags_
.PP
\fBACE_Task\fR flags.
.PP
.SS int ACE_Task_Base::grp_id_
.PP
This maintains the group id of the Task.
.PP
.SS size_t ACE_Task_Base::thr_count_
.PP
Count of the number of threads running within the task. If this value is great 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. 
.SS \fBACE_Thread_Manager\fR * ACE_Task_Base::thr_mgr_
.PP
Multi-threading manager.
.PP


.SH AUTHOR
.PP 
Generated automatically by Doxygen for ACE from the source code.