Re: possibly ot: thread suspension
On May 13, 1:29 am, "Chris Thomasson" <cris...@comcast.net> wrote:
"Szabolcs Ferenczi" <szabolcs.feren...@gmail.com> wrote in message
news:dd13a776-05a7-440f-9d3f-85e9be1f975b@d77g2000hsb.googlegroups.com...
On May 12, 9:15 am, Chris Forone <4...@gmx.at> wrote:
how does a thread suspend itself? is a volatile bool enough,
that is checked after each loop?
[...]
If you want to check the return values of the library operations
You must check the return values of pthread calls. IMVHO,
applications that fail to at least check status of pthread
calls are crap.
I more or less agree, but... What do you do if
pthread_mutex_lock() fails? In many cases, the only possible
cause of failure will be a programming error elsewhere, or
insufficient resources. In both cases, most of the time, about
all you can reasonably do is abort with an error message.
(You definitely do have to consider the case, of course. If
pthread_mutex_lock() returns with an error, you do NOT have the
lock.)
your code will be even more complex.
Why? You can wrap the raw API calls.
Generally, you should have anything at that low a level wrapped
in a class anyway.
--
James Kanze (GABI Software) email:james.kanze@gmail.com
Conseils en informatique orient=E9e objet/
Beratung in objektorientierter Datenverarbeitung
9 place S=E9mard, 78210 St.-Cyr-l'=C9cole, France, +33 (0)1 30 23 00 34