|
Boost Users : |
From: David Abrahams (dave_at_[hidden])
Date: 2005-04-07 10:47:08
"C. Michailidis" <dinom_at_[hidden]> writes:
> Quoting from
> http://www.boost.org/doc/html/threads/concepts.html#threads.concepts.mutexes
>
> "Many C++ threading libraries use a pattern known as Scoped
> Locking[SchmidtStalRohnertBuschmann] to free the programmer from the need to
> explicitly lock and unlock mutex objects. With this pattern, a Lock concept
> is employed where the lock object's constructor locks the associated mutex
> object and the destructor automatically does the unlocking. The Boost.Threads
> library takes this pattern to the extreme in that Lock concepts are the only
> way to lock and unlock a mutex object: lock and unlock functions are not
> exposed by any Boost.Threads mutex objects. This helps to ensure safe usage
> patterns, especially when code throws exceptions."
>
> Unfortunately, I actually WANT to shoot myself in the foot this time and
> Boost.Threads won't let me!!! I can understand ENCOURAGING users to write
> safe code, but forcing them to is outright fascist!
Nobody's forcing you to use the library ;-)
> My problem is that I have existing code which I would like to make more
> portable by using Boost.Threads. Now, this wouldn't be a problem except for
> the fact that I'm (effectively) dealing w/ a COM object that already has its
You can dynamically allocate lock objects, or you can dynamically
construct them using boost::optional.
HTH,
-- Dave Abrahams Boost Consulting www.boost-consulting.com
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