
"Preston A. Elder" <prez@neuromancy.net> writes:
On Tue, 13 Nov 2007 19:50:04 +0000, Preston A. Elder wrote:
Ironically, the new interface makes this whole thing harder. Mainly because of two reasons:
OK, I take it all back!
;-)
Here is my new interruptable_mutex, using the new boost::thread: http://www.neuromancy.net/fisheye/browse/mantra/trunk/Mantra-I/mantra/utils/...
It turns out it is much simpler to implement ;)
Excellent. I think there's a bug in your timed_lock --- it doesn't quit when the timeout expires. Easy to fix --- just check the return value from m_cond.timed_wait. Anyway, your code demonstrates why it needs to be a separate type to boost::mutex --- it uses two mutexes (one internal, one external) and a condition variable in the implementation, which is quite heavyweight.
The nice thing about this is it is a template, so any lock type can be used with this lock. Of course, it has t have a try_lock() and unlock() function.
That's good --- it fits in nicely with the new thread library interfaces. Anthony -- Anthony Williams Just Software Solutions Ltd - http://www.justsoftwaresolutions.co.uk Registered in England, Company Number 5478976. Registered Office: 15 Carrallack Mews, St Just, Cornwall, TR19 7UL