From: klaus triendl (klaus_at_[hidden])
Date: 2008-03-16 10:55:11
is there any interest in something like a locking pointer and a type
that I call "lockable" that pairs any type with a mutex?
Inspired by Andrei Alexandrescu's article "volatile - Multithreaded
Programmer's Best Friend" on ddj I implemented a concept similar to a
locking pointer called "lock_acquirer" that collects acquisition of a
mutex and a volatile cast of the locked type. It is even more threadsafe
to use than a locking pointer.
Additionally I made a class "lockable" that pairs a (volatile) type with
a mutex type, wrapping both in a distinct type, which has first the
advantage that the type to protect and the mutex are glued together, and
second that it encapsulates volatile qualifier correctly.
Also, the locked type in a lockable can, if wanted, by a restricted
interface only be accessed by a lock_acquirer thus forcing the
programmer to a very threadsafe programming style.
I can post my implementation along with a simple example to the boost vault.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk