|
Boost : |
From: Gennadiy Rozental (gennadiy.rozental_at_[hidden])
Date: 2003-02-19 05:25:51
> > Mutex locking is a simple example of resource management idiom. All
flavors
> > of resource management are easily implemented in terms of policy based
smart
> > pointers (don't allow name to confuse you). In this particular case most
> > probably all that you need is a custom StoragePolicy. Now you can enjoy
all
> > the variety of ownership policies supplied with smart_ptr or design your
own
> > for very specific needs.
>
> To use an old English idiom, I think you are putting the cart before the
> horse [as did Modern C++ Design, IMNSHO]
>
> Resource protection is a useful concept, and pointers are simply another
> resource that needs protecting. It makes little sense to dereference a
> mutex, for instance. This is one of the defining concepts of a pointer.
>
> Rather, I think if we seek a generic implementation the 'base' concept
> is resource protection, and smart pointers are a refinement of this
> concept.
First of all let me emphasize that it seems that we agree that this kind of
task require some generic component based implementation.
Now about the "order". smart_ptr checking policy allows prohibit at compile
time using of operator* or operator->, effectively removing them from public
interface on the resource manager class. On the other hand in some cases we
need to provide an access to managed resource (for example to call methods
of it). Aforementioned operators could be very handy in this case. So I
don't think that smart_ptr interface does not fit for the purpose of generic
resource manager. In any case it's details of implementation, that we may
discuss during pbsp review.
Gennadiy.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk