[c++-pthreads] Re: What are the real issues?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[c++-pthreads] Re: What are the real issues?



On Jan 6, 2004, at 10:06 PM, Fergus Henderson wrote:

The point of standardizing a particular cancellation framework
is to enable interoperability between code written by different parties.
For example, this is needed to allow application code to cancel threads
which happen to be running third-party library code, or even standard
library code such as getchar() or system calls such as read().

Thanks, I appreciate the need for code written by different parties to work together in a thread/cancel environment.

In the scenario I've outlined, code written by different parties would work together in a thread/cancel environment as long as:

1.  The code met basic exception safety requirements.
2. The code was not compute-bound (and thus ignored cancellation requests).

For example, I could've sprinkled my helloworld with std::lib calls, and it still would've been ok because the std::lib maintains basic exception safety. Admittedly if a std::lib call took an inordinate amount of time, cancellation requests would be ignored during that call. But it seems we already have the risk of ignoring cancellation requests anyway.

You correctly point out that YourLib would not recognize cancellation requests from MyLib. However, YourLib could correctly clean up its resources in the event that it called MyLib which subsequently initiated cancellation. Is that sufficient interoperability?

-Howard