Boost logo

Boost Users :

From: KSpam (keesling_spam_at_[hidden])
Date: 2007-10-06 15:26:13


Woody,

On Thursday 04 October 2007 08:05:44 Steven Woody wrote:
> thanks a lot for your code which cleared most of my question. while
> the scoped_lock can has a thread block when a mutex object is being
> locked by another thread, can you show me additional example about how
> to let a thread immediately exit when it found a mutex object is being
> used? i mean that one of thread in our application is actually the
> GUI main thread, it will access the shared data in it's OnIdel event
> handler, so i hope it will be never blocked, when resources are not
> available, i hope it can immediately exist and try again some times
> later. does the boost support this kind of feature? thanks.

It sounds like you might want to use a try_mutex and a scoped_try_lock. I
have not personally used this construct, but you can find documentation in
the following locations:

http://boost.org/doc/html/boost/try_mutex.html
http://boost.org/doc/html/thread/concepts.html#thread.concepts.ScopedTryLock
http://boost.org/doc/html/thread/concepts.html#thread.concepts.TryLock

The only example I see in the boost distribution (1.34.1) is
libs/thread/test/test_mutex.cpp.

Justin


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net