3 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
11 <font face=helvetica size=
5>ACE Frequently Made Mistakes
</font>
15 <table border=
0 cellpadding=
3 cellspacing=
1 width=
550>
18 <td align=right valign=top
>
21 <td align=left valign=top
>
22 ACE_Task::getq() returns the error
23 <b>resource temporarily unavailable
</b>
27 <td align=right valign=top
>
30 <td align=left valign=top
>
31 Your Task is a subclass of ACE_Task
<ACE_NULL_SYNCH
> and
32 you are using it in a multithreaded program.
36 <td align=right valign=top
>
39 <td align=left valign=top
>
40 Try using ACE_Task
<ACE_MT_SYNCH
>
41 instead so that the associated Message_Queue
42 is configured for access by multiple threads.
44 <tr><td colspan=
2><hr noshade
></td></tr>
47 <td align=right valign=top
>
50 <td align=left valign=top
>
51 ACE_Task::wait() throws an assert violation
55 <td align=right valign=top
>
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
65 <td align=right valign=top
>
68 <td align=left valign=top
>
69 Make sure you specify the flag THR_JOINABLE when activating
72 <tr><td colspan=
2><hr noshade
></td></tr>
77 <td align=right valign=top
>
80 <td align=left valign=top
>
81 Apparent race conditions when spawning threads (or activating Tasks)
82 from within a constructor.
86 <td align=right valign=top
>
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.
98 <td align=right valign=top
>
101 <td align=left valign=top
>
102 Move your Task activations and other thread-spawning activities
103 <b>out
</b> of the constructor.
105 <tr><td colspan=
2><hr noshade
></td></tr>
110 <td align=right valign=top
>
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".
119 <td align=right valign=top
>
120 <b>probable cause
</b>
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.
129 <td align=right valign=top
>
132 <td align=left valign=top
>
133 Instead of instantiating a template class like
<b>ACE_Svc_Handler
<<u>ACE_SOCK_Stream
</u>, ACE_NULL_SYNCH
></b>, use the form of
<b>ACE_Svc_Handler
<<u>ACE_SOCK_STREAM
</u>, ACE_NULL_SYNCH
></b> which circumvents the platform peculiarities by using the macro. This also applies to some other template classes.
135 <tr><td colspan=
2><hr noshade
></td></tr>
140 <td align=right valign=top
>
143 <td align=left valign=top
>
144 Unable to compare ACE_thread_t variables (such as ACE_Thread::self())
149 <td align=right valign=top
>
150 <b>probable cause
</b>
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.
160 <td align=right valign=top
>
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.
167 <tr><td colspan=
2><hr noshade
></td></tr>
170 <td align=right valign=top
>
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.
179 <td align=right valign=top
>
180 <b>probable cause
</b>
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
189 <td align=right valign=top
>
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().
197 <tr><td colspan=
2><hr noshade
></td></tr>
204 <td align=right valign=top
>
207 <td align=left valign=top
>
208 Infinite recursion when you invoke ACE_Reactor::remove_handler()
212 <td align=right valign=top
>
213 <b>probable cause
</b>
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
222 <td align=right valign=top
>
225 <td align=left valign=top
>
226 Be sure to
<b>OR
</b> in the DONT_CALL flag in this situation.
<br>
229 int MyHandler::handle_close (ACE_HANDLE handle,
230 ACE_Reactor_Mask close_mask)
233 my_reactor_-
>remove_handler( this,
234 ACE_Event_Handler::READ_MASK |
235 ACE_Event_Handler::DONT_CALL );
242 <tr><td colspan=
2><hr noshade
></td></tr>
245 <td align=right valign=top
>
248 <td align=left valign=top
>
249 Application crashes after deleting Event_Handler.
253 <td align=right valign=top
>
254 <b>probable cause
</b>
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.
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>
274 <td align=right valign=top
>
277 <td align=left valign=top
>
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.
282 <li>Remember to call
<tt>purge_pending_notifications()
</tt>,
283 <tt>remove_handler()
</tt> and
<tt>cancel_timer()
</tt> before deleting the
288 <td align=left valign=top
>
291 <tr><td colspan=
2><hr noshade
></td></tr>
296 <td align=right valign=top>
299 <td align=left valign=top>
304 <td align=right valign=top>
305 <b>probable cause</b>
307 <td align=left valign=top>
312 <td align=right valign=top>
315 <td align=left valign=top>
318 <tr><td colspan=2><hr noshade></td></tr>
322 <td align=center colspan=
2>
323 <font size=
2>maintained by
<a href=
"mailto:bob@werken.com">bob@werken.com
</a></font>
329 Back to
<A HREF=
"index.html">ACE Documentation Home
</A>.