Re: [c++-pthreads] Re: I'm Lost
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Re: I'm Lost



In message <42E7709F.AE07F97A@xxxxxx>, Alexander Terekhov <terekhov@xxxxxx> writes

Wil Evers wrote:
[...]
I'd say it's time to face the truth, which is that POSIX cancellation
semantics are incompatible with commonly established C++ coding
practices.

It's incompatible with cancel-unaware C++ code. Note that it's
incompatible with cancel-unaware C code as well, but that didn't
stop POSIX and ongoing creation of cancel-safe code in both C
and C++ languages. Very many tons of cancel-safe code.

To the best of my knowledge there have been zero lines of cancel-safe C++ code written against the C++ binding of POSIX threads.

Of course, C and C++ have an intimate relationship, but that does not mean to say that they are the same or that C++ must slavishly follow the same model that C has decided on. There is a question of interoperability, but that is not the same as portability. The discussion so far seems to have taken the latter view, which is subtly different.

If the C++ binding chooses to throw exceptions for cancellation, no C++ code will be broken by silent changes. Code written in C++ that is correct against the C binding will continue to be correct against that binding. But should the program be modified to take advantage of a C++ binding, that guarantee no longer holds. However, this is unsurprising and is to be expected of any migration between APIs. Of course, it makes sense to minimise gratuitous differences, but minimal difference is not the same as no difference.

Kevlin
--
____________________________________________________________

  Kevlin Henney                   phone:  +44 117 942 2990
  mailto:kevlin@xxxxxxxxxxxxx     mobile: +44 7801 073 508
  http://www.curbralan.com        fax:    +44 870 052 2289
  Curbralan: Consultancy + Training + Development + Review
____________________________________________________________