Re: [c++-pthreads] Re: cancellation points report failure
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Re: cancellation points report failure



Nathan Myers wrote:
> 
> On Tue, Jan 06, 2004 at 06:58:57AM -0500, Dave Butenhof wrote:
> > Personally, I would be happy to accept a C++ binding with no way to
> > enable asynchronous cancelability, and to avoid defining any C++ code
> > as "async cancel-safe".
> 
> I think we're all agreed on that.  This list is about semantics of
> a C++ binding for synchronous cancellation.

Objection. To begin with, asynchronous cancelability IS part of 
pthreads. Well, 

void operation();
blabla another_operation( ...blablabla... ) async_cancel_safe; 

void operation() {

  // cancel points DO throw here (if expected)

  async_cancel { // cancel type = ASYNC

    // only async-cancel-safe operations
    // are allowed here. Error/ill-formed 
    // otherwise. for example:
    another_operation(); // OK

    sync_cancel { // cancel type = SYNC/DEFERRED

      // Back to usual 
 
      no_cancel { 

        // cancel points do NOT throw here
  
      }

      // Back to usual 

    }

    // only async-cancel-safe operations
    // are allowed here. Error/ill-formed 
    // otherwise.

    no_cancel { // cancel *TYPE* = SYNC/DEFERRED

      // cancel points do NOT throw here
  
    }

    // only async-cancel-safe operations
    // are allowed here. Error/ill-formed otherwise.

  }

  // cancel points DO throw here

  no_cancel { 

    // cancel points do NOT throw here
  
  }

  // cancel points DO throw here

}

blabla another_operation( ...blablabla... ) async_cancel_safe {
//                                          ^^^^^^^^^^^^^^^^^
// async_cancel_safe implies "async_cancel {" scope
// restrictions/safety for body (on entry) AND
// "blablabla" parameters PLUS "blabla-return-value" too!

  // only async-cancel-safe operations
  // are allowed here. Error/ill-formed 
  // otherwise.

  sync_cancel { // cancel type = SYNC/DEFERRED

     // Back to usual 
  
     no_cancel { 

        // cancel points do not throw here

     }

     // Back to usual 

  }

  // only async-cancel-safe operations
  // are allowed here. Error/ill-formed 
  // otherwise.

  no_cancel { // cancel *TYPE* = SYNC/DEFERRED

    // cancel points do NOT throw here
  
  }

  // only async-cancel-safe operations
  // are allowed here. Error/ill-formed 
  // otherwise.

  return ...;

}

regards,
alexander.