
----- Original Message ----- From: "Anthony Williams" <anthony.ajw@gmail.com> To: <boost@lists.boost.org> Sent: Tuesday, January 20, 2009 3:42 PM Subject: Re: [boost] [thread] Exception based timed locks
"vicente.botet" <vicente.botet@wanadoo.fr> writes:
I've read recently about timed locks throwing an exception when there is a timeout. What do you think about this behaviour? Could the thread library provide both?
Interesting idea. It certainly tidies up the code, which is one of my favourite features of exceptions.
What do you think about a try_lock_until, try_lock_for functions
while (polling) try { boost::try_lock_for(100, m1, m2, m3); foo(); polling = false; } catch (timeout_exception& ex) {execute_on_failed(); }
Hmm. Interesting. Have you got some realistic use cases?
Well, the use cases are no different from the ones for the function template lock(), and a timed_lock(). I think that timed locks are used primarily for polling models and locking all the timeouts at once with a timeout guard seems natural. Unfortunately I can't give you a concrete example, but I'm sure other in this ML will find a lot of them. Could the thread library provide something like that? Thanks, Vicente