Boost logo

Boost :

From: Aleksey Gurtovoy (alexy_at_[hidden])
Date: 2001-07-21 11:06:01


Vesa Karvonen wrote:
> Personally, I have been using a class template 'locked',
> which is basically a handle to a lockable or guarded
> object/resource. It is similar to, but not the same as, the
> LockingPtr presented in
> http://www.cuj.com/experts/1902/alexandr.htm?topic=experts.
> The main implementation difference is that lockable only
> stores a single pointer.
>
> The following mainly describes guarded, which is a simple
> template I developed a long time ago. I haven't noticed the
> same concept anywhere before, but I suspect that it can be
> found in many C++ libraries for concurrent programming.
> (I have not been doing concurrent programming for some time
> now, so I haven't been looking into concurrent programming
> libraries.) The reason why I'm describing guarded here is
> because I believe it can be quite useful, and I believe it
> should not be ignored while implementing locking
> components, and also because it demonstrates a solution in
> which the type of a resource basically changes when it is
> acquired (in this case from guarded<interface> to interface).
> I'm also interested to know of other implementations and
> refinements of this concept.

There was a long thread in news:comp.lang.c++.moderated regarding the
Andrei's LockingPtr technique, and I believe that 'need_locking' class
template described in the following article:

http://groups.google.com/groups?th=9e0488ed4f4a80f4,426&rnum=185&selm=94ccng
%24m2t%241%40nnrp1.deja.com

is pretty much equivalent to your 'guarded' class.

Aleksey


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk