RE: [Boost-Users] Boost.Threads question
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...) Thanks again for the help, very much appreciated. James Info: http://www.boost.org Wiki: http://www.crystalclearsoftware.com/cgi-bin/boost_wiki/wiki.pl Unsubscribe: mailto:boost-users-unsubscribe@yahoogroups.com Your use of Yahoo! Groups is subject to http://docs.yahoo.com/info/terms/
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
participants (2)
-
James Zappia
-
William E. Kempf