Boost logo

Boost Users :

Subject: Re: [Boost-users] Boost-users] question about threading library
From: Tan, Tom (Shanghai) (TTan_at_[hidden])
Date: 2008-11-06 22:49:52


Please read this link by the author of boost.thread:
http://www.devx.com/SpecialReports/Article/38883/1954?pf=true,
He also has a personal blog worth reading:
http://www.justsoftwaresolutions.co.uk/

concerning your specific questions:

1. boost::mutex::scoped_lock is just a typedef of unique_lock<mutex>
inside mutex. With this kind of typedef, you'll be able to use the same
type scoped_lock for other kind of mutex(
For example Timed_mutex ) by changing the mutex type only.
There IS the definition on this page:
http://www.boost.org/doc/libs/1_37_0/doc/html/thread/synchronization.htm
l#thread.synchronization.mutex_types

2. " std::lock_guard is deliberately basic and can only be used as
shown. On the other hand, std::unique_lock allows for deferred locking,
trying to lock, trying to lock with a timeout, and unlocking before the
object is destroyed. "(copied from the first link above)

HTH.

>From: "Robert Ramey" <ramey_at_[hidden]>
>Subject: [Boost-users] question about threading library
>
>I want to use the boost threading library in an application.
>
>Looking through the documentation, I have a questions.

>a) in the examples I find "boost::mutex::scoped_lock" but
>I don't find this in the documentation. It looks like this
>is called "lock_guard". What should I be doing here.

>b) Its not clear to me how unique_lock(Lockable l)
>is different than using lock_gard(..) or scoped_lock.

>Robert Ramey

**************************************


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