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