Boost logo

Boost Users :

From: Raúl Huertas (raulh39_at_[hidden])
Date: 2006-12-11 14:54:48


Boris Kolpackov escribió:
> Hi Roland,
>
> Roland Schwarz <roland.schwarz_at_[hidden]> writes:
>
>
>> If you carefully rethink the need for cancellation you most likely will
>> find that you really will need cancellation rarely. You almost always
>> can use some other interthread communication mechanisms.
>>
>
> It also almost always requires sneaking an ugly "special case" into
> an otherwise clean and simple code (e.g., a special cancellation pipe
> for a thread waiting on select, a special flag for a thread waiting on
> condvar, etc.).
Yes, it is ugly ;), but thread cancellation is not a special case, IMHO.
In my point of view, it has to be part of all the code that the thread
uses. For me, it is important that the programmer thinks about what
parts of the code can be cancellated and how to react to this cancellation.

> It is in essence very similar to the exceptions vs
> error codes debate; as with exceptions, with proper thread cancellation
> you can separate the main logic from the thread termination code.
>
>
>
Yes, it is similar in essence, but I reserve exceptions for the
exceptional cases ;), and I'm not sure that thread cancellation can be
an exceptional case. For example, I use exceptions when my programs runs
out of file descriptors, but I do not use them when I can't open a file.
I suppose that, in the end, it is a matter of tastes, but I don't like
that the programmers don't think about thread cancellation because an
automated mechanism (similar to exceptions) dos the job for them. I only
let the programmers not to think when the job is very easy... ;)

Just my two cents...

Raul.
P.S.: Forgive my English, I'm trying hard to learn it...


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net