Boost logo

Boost Users :

From: Jason Winnebeck (yg-boost-users_at_[hidden])
Date: 2003-08-01 07:17:15


Mark Sizer wrote:
> static bool ReceiverBody::bShuttingDown()
> {
> bool bLocalStop = false;
> { boost::mutex::scoped_lock lockStop( _mutexStop );
> bLocalStop = _bStop;
> }
>
> return bLocalStop;
> }
> Note that this can't be const, even though it sort-of is. It modifies
> the mutex, even though that doesn't matter to the logical state of the
> object.

Mark, a tip on that. I don't know if this applies to boost mutex or
not, but if their system is like mine, then you can declare _mutexStop
with the mutable keyword. Then you can declare the method bShuttingDown
as const. At first it might seem like a bad thing, saying const when
you really don't mean it, but I believe that for member functions const
means that the state of the object does not change as a result of the
function -- and it won't, because the state before and after is the same.

Jason


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net