Re: [c++-pthreads] Re: thread-safety definition
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [c++-pthreads] Re: thread-safety definition



Dave Butenhof wrote:
[...]
> >>Ted, when he says "RAII", he means "Resource Acquision is Initialization".
> >>
> >>
> >To me, this doesn't say much at all in the context of enabling/disabling
> >and/or disabling/enabling cancellation via "RAII guard objects". The link
> >OTOH does illustrate it (e.g. see "class cancel_off_guard").
> >
> >
> OK, so let's be more specific, Alexander. You would have been fine ...

Specifically, I meant something along the lines of

class cancel_OFF_to_ON_guard {

  //*** unimplemented since it's non-copyable/non-copy-constructible
  cancel_OFF_to_ON_guard(const cancel_OFF_to_ON_guard &);
  cancel_OFF_to_ON_guard & operator=(const cancel_OFF_to_ON_guard &);

public:

  cancel_OFF_to_ON_guard() throw() {
    int status;
    status = pthread_setcancelstate(PTHREAD_CANCEL_ENABLE, &status);
    assert(!status);
  }

 ~cancel_OFF_to_ON_guard() throw() {
    int status;
    status = pthread_setcancelstate(PTHREAD_CANCEL_DISABLE, &status);
    assert(!status);
  }

};

Okay now?

regards,
alexander.