Cleanup ACE_HAS_PTHREAD_SIGMASK_PROTOTYPE, all platforms support it so far as I can...
[ACE_TAO.git] / ACE / docs / ACE-FMM.html
blob4122d84ea14039ee30270793997cf3fd3611f6f1
1 <!-- -->
3 <!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
4 <html>
5 <head>
6 <title>ACE FMM</title>
7 </head>
9 <body bgcolor=#ffffff>
10 <center>
11 <font face=helvetica size=5>ACE Frequently Made Mistakes</font>
13 <br>
14 <br>
15 <table border=0 cellpadding=3 cellspacing=1 width=550>
17 <tr>
18 <td align=right valign=top>
19 <b>symptom</b>
20 </td>
21 <td align=left valign=top>
22 ACE_Task::getq() returns the error
23 <b>resource temporarily unavailable</b>
24 </td>
25 </tr>
26 <tr>
27 <td align=right valign=top>
28 <b>probable cause</b>
29 </td>
30 <td align=left valign=top>
31 Your Task is a subclass of ACE_Task&lt;ACE_NULL_SYNCH&gt; and
32 you are using it in a multithreaded program.
33 </td>
34 </tr>
35 <tr>
36 <td align=right valign=top>
37 <b>solution</b>
38 </td>
39 <td align=left valign=top>
40 Try using ACE_Task&lt;ACE_MT_SYNCH&gt;
41 instead so that the associated Message_Queue
42 is configured for access by multiple threads.
43 </td>
44 <tr><td colspan=2><hr noshade></td></tr>
46 <tr>
47 <td align=right valign=top>
48 <b>symptom</b>
49 </td>
50 <td align=left valign=top>
51 ACE_Task::wait() throws an assert violation
52 </td>
53 </tr>
54 <tr>
55 <td align=right valign=top>
56 <b>probable cause</b>
57 </td>
58 <td align=left valign=top>
59 When you activate()d your Task, you specified
60 THR_DETACHED, which causes wait() to be unable to perform what you
61 want it to.
62 </td>
63 </tr>
64 <tr>
65 <td align=right valign=top>
66 <b>solution</b>
67 </td>
68 <td align=left valign=top>
69 Make sure you specify the flag THR_JOINABLE when activating
70 your ACE_Task object.
71 </td>
72 <tr><td colspan=2><hr noshade></td></tr>
76 <tr>
77 <td align=right valign=top>
78 <b>symptom</b>
79 </td>
80 <td align=left valign=top>
81 Apparent race conditions when spawning threads (or activating Tasks)
82 from within a constructor.
83 </td>
84 </tr>
85 <tr>
86 <td align=right valign=top>
87 <b>probable cause</b>
88 </td>
89 <td align=left valign=top>
90 You are not guaranteed to have a valid <b>this</b> pointer
91 until the constructor has exited. Threads spawned from
92 a constructor are free to run
93 immediately, and may attempt to use an invalid <b>this</b> pointer.
95 </td>
96 </tr>
97 <tr>
98 <td align=right valign=top>
99 <b>solution</b>
100 </td>
101 <td align=left valign=top>
102 Move your Task activations and other thread-spawning activities
103 <b>out</b> of the constructor.
104 </td>
105 <tr><td colspan=2><hr noshade></td></tr>
109 <tr>
110 <td align=right valign=top>
111 <b>symptom</b>
112 </td>
113 <td align=left valign=top>
114 Compiler issues warnings/erros regarding using too few template
115 arguments, such as "'ACE_Svc_Handler' : too few template arguments".
116 </td>
117 </tr>
118 <tr>
119 <td align=right valign=top>
120 <b>probable cause</b>
121 </td>
122 <td align=left valign=top>
123 Instead of using the appropriate macro, you supplied an actual class
124 name as a parameter. This will fail depending upon platform and compiler,
125 due to the way templates are handled.
126 </td>
127 </tr>
128 <tr>
129 <td align=right valign=top>
130 <b>solution</b>
131 </td>
132 <td align=left valign=top>
133 Instead of instantiating a template class like <b>ACE_Svc_Handler&lt;<u>ACE_SOCK_Stream</u>, ACE_NULL_SYNCH&gt;</b>, use the form of <b>ACE_Svc_Handler&lt;<u>ACE_SOCK_STREAM</u>, ACE_NULL_SYNCH&gt;</b> which circumvents the platform peculiarities by using the macro. This also applies to some other template classes.
134 </td>
135 <tr><td colspan=2><hr noshade></td></tr>
139 <tr>
140 <td align=right valign=top>
141 <b>symptom</b>
142 </td>
143 <td align=left valign=top>
144 Unable to compare ACE_thread_t variables (such as ACE_Thread::self())
145 using operator== ().
146 </td>
147 </tr>
148 <tr>
149 <td align=right valign=top>
150 <b>probable cause</b>
151 </td>
152 <td align=left valign=top>
153 On some platforms, thread ids are numeric, and on some, they aren't. On some
154 implementations, simple a == b comparisons
155 are legal and sane. Some are not.
157 </td>
158 </tr>
159 <tr>
160 <td align=right valign=top>
161 <b>solution</b>
162 </td>
163 <td align=left valign=top>
164 Use the <b>ACE_OS::thr_equal()</b> function to reliably compare thread
165 ids, regardless of platform.
166 </td>
167 <tr><td colspan=2><hr noshade></td></tr>
169 <tr>
170 <td align=right valign=top>
171 <b>symptom</b>
172 </td>
173 <td align=left valign=top>
174 ACE_Reactor::run_event_loop() does not seem to function correctly
175 for a Reactor created in your application.
176 </td>
177 </tr>
178 <tr>
179 <td align=right valign=top>
180 <b>probable cause</b>
181 </td>
182 <td align=left valign=top>
183 You have not set the ACE_Reactor::instance() to refer to your new reactor.
184 run_event_loop only functions on the reactor currently installed as the
185 global Singleton.
186 </td>
187 </tr>
188 <tr>
189 <td align=right valign=top>
190 <b>solution</b>
191 </td>
192 <td align=left valign=top>
193 Use the <b>ACE_Reactor::instance(ACE_Reactor *,
194 int delete_reactor = 0)</b> static method to install your reactor as the global
195 Singleton before calling run_event_loop().
196 </td>
197 <tr><td colspan=2><hr noshade></td></tr>
203 <tr>
204 <td align=right valign=top>
205 <b>symptom</b>
206 </td>
207 <td align=left valign=top>
208 Infinite recursion when you invoke ACE_Reactor::remove_handler()
209 </td>
210 </tr>
211 <tr>
212 <td align=right valign=top>
213 <b>probable cause</b>
214 </td>
215 <td align=left valign=top>
216 You are invoking remove_handler() from within handle_close() (or a
217 method invoked by handle_close()) but you have not specified the
218 DONT_CALL flag.
219 </td>
220 </tr>
221 <tr>
222 <td align=right valign=top>
223 <b>solution</b>
224 </td>
225 <td align=left valign=top>
226 Be sure to <b>OR</b> in the DONT_CALL flag in this situation.<br>
227 e.g. --<br>
228 <ul><pre>
229 int MyHandler::handle_close (ACE_HANDLE handle,
230 ACE_Reactor_Mask close_mask)
233 my_reactor_-&gt;remove_handler( this,
234 ACE_Event_Handler::READ_MASK |
235 ACE_Event_Handler::DONT_CALL );
237 return 0;
239 </pre></ul>
241 </td>
242 <tr><td colspan=2><hr noshade></td></tr>
244 <tr>
245 <td align=right valign=top>
246 <b>symptom</b>
247 </td>
248 <td align=left valign=top>
249 Application crashes after deleting Event_Handler.
250 </td>
251 </tr>
252 <tr>
253 <td align=right valign=top>
254 <b>probable cause</b>
255 </td>
256 <td align=left valign=top>
257 You left a dangling pointer to the Event_Handler in the Reactor.
258 It is the application's responsibility to remove all pending notifications,
259 timer events and completely remove the event handler I/O registrations
260 before removing the event handler.
262 Also, the application should remove the event handler from the reactor
263 <b>before</b> closing the underlying file descriptor / handle.
264 Otherwise:
265 <ul>
266 <li>The reactor does not know how to remove the event handler, because the
267 handle is used as the identifier for the event handlers</li>
268 <li>The file descriptor / handle may be reused by another thread, leading to
269 nasty race conditions.</li>
270 </ul>
271 </td>
272 </tr>
273 <tr>
274 <td align=right valign=top>
275 <b>solution</b>
276 </td>
277 <td align=left valign=top>
278 <ul>
279 <li>Use reference counted event handlers. The reactor and the application
280 cooperate to remove the event handler when the last reference goes away.
281 </li>
282 <li>Remember to call <tt>purge_pending_notifications()</tt>,
283 <tt>remove_handler()</tt> and <tt>cancel_timer()</tt> before deleting the
284 event handler.
285 </li>
286 </ul>
287 </td>
288 <td align=left valign=top>
290 </td>
291 <tr><td colspan=2><hr noshade></td></tr>
293 <!--
295 <tr>
296 <td align=right valign=top>
297 <b>symptom</b>
298 </td>
299 <td align=left valign=top>
301 </td>
302 </tr>
303 <tr>
304 <td align=right valign=top>
305 <b>probable cause</b>
306 </td>
307 <td align=left valign=top>
309 </td>
310 </tr>
311 <tr>
312 <td align=right valign=top>
313 <b>solution</b>
314 </td>
315 <td align=left valign=top>
317 </td>
318 <tr><td colspan=2><hr noshade></td></tr>
321 <tr>
322 <td align=center colspan=2>
323 <font size=2>maintained by <a href="mailto:bob@werken.com">bob@werken.com</a></font>
324 </td>
325 </tr>
327 </table>
328 </center>
329 Back to <A HREF="index.html">ACE Documentation Home</A>.
330 </body>
331 </html>