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
- To: Dave Butenhof <David.Butenhof@xxxxxx>
- Subject: Re: [c++-pthreads] Re: thread-safety definition
- From: Alexander Terekhov <boo@xxxxxxxxxxx>
- Date: Wed, 14 Jan 2004 16:50:42 +0100
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.