Boost logo

Boost :

From: Lee Brown (lee_at_[hidden])
Date: 2002-01-16 22:47:18


> I really don't think you should. Most of what you've had to say has
> been beneficial. I think that sometimes you're too stuck on POSIX
> and not willing enough to try and envision how things should be for a
> language that POSIX truly doesn't cover, but your knowledge of POSIX

What about being stuck on exceptions? A lot of C++
programmers do not use exceptions, because they increase code size
dramatically. Are we to think they shouldn't have access to a C++ API for
thread cancelation?

Furthermore....

I believe, throw is like setting "errno" and then using a "goto" statement.

If this is true, the "C++ stack" is actually the lowly "goto" statement.
i.e.

some_func() {
   Widget m;
    
   if (true) throw 1;
    
   m=2;
}

is equivalent to:

some_func() {
    struct c_widget m;
    c_widget_init(&m);
    
    if(true) {
        errno = 1;
            goto cleanup1;
     }

    m=2;

  cleanup 1 :
        c_widget_exit(&m);
}

A thread can be canceled in the middle of a throw.
Yes, the code they call saves us
a lot of trouble but it is code that may never be executed.
In a cancel enabled envirionment we can not use goto statements to restore
resources, we must use cancel_push and cancel_pop.

It seems to me POSIX threads are correct. If cancelation is to be implemented
it would probably be wise to move towards their model with a more handsome
and convenient API. This API would also assist in covering up any ugly
implementations details imposed by less sophisticated platforms.

But then again, I could be wrong. It wouldn't be the first time.

lee


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk