Boost logo

Boost :

Subject: Re: [boost] [thread] Exception based timed locks
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-20 13:43:53


----- Original Message -----
From: "Anthony Williams" <anthony.ajw_at_[hidden]>
To: <boost_at_[hidden]>
Sent: Tuesday, January 20, 2009 3:42 PM
Subject: Re: [boost] [thread] Exception based timed locks

>
> "vicente.botet" <vicente.botet_at_[hidden]> 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


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk