Boost logo

Boost Users :

From: William E. Kempf (wekempf_at_[hidden])
Date: 2002-12-04 13:48:04


James Zappia said:
> Thank you, that worked. I see what I was doing wrong.
>
> One thing I don't understand about the alternative method...
>
>> boost::try_mutex::scoped_try_lock lock(mutex); // does a try_lock
>> while (!lock) {
>> cout << "trying...";
>> lock.try_lock();
>> }
>
> How does "!lock" in the "while (!lock) { ... }" statement determine
> whether it's true or false? Does it call a function in the
> scoped_try_lock class? (sorry if that's a lame question...)

Hmmm... this doesn't seem to be documented very well. I'll have to fix
that. What it does is invoke operator void*() for a boolean test (this
mechanism also should be updated to use the safe_bool idiom as well).
Alternatively, you could call lock.locked() (which also appears to be
poorly documented). Thanks for pointing out these deficiencies.

William E. Kempf


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