|
Boost : |
Subject: Re: [boost] [rfc] rcpp
From: Daniel Trebbien (dtrebbien_at_[hidden])
Date: 2010-02-28 12:06:02
I think that this library has potential. Writing resource-managing
classes can lead to bugs very easily, so having a generic solution to
the problem of creating resource-managing classes is definitely
appealing. However, I think that the library can use a little more
generality.
For example, it would be nice if the resource config had an
`is_invalid` member. This would be useful in creating a resource
manager for Windows `HANDLE`s that result from calls to
`DuplicateHandle`. I need to keep track of the `DuplicateHandle`
return value so that I would know whether the `HANDLE` member of the
resource manager is set to something that needs to be closed with
`CloseHandle`. Essentially the underlying resource type in this case
is a pair of a `HANDLE` and `BOOL`, where the "invalid value" is a
pair with the `BOOL` set to `FALSE` and an indeterminate value of the
`HANDLE`. In order to use the `rcpp::resource` template, I would need
to override the `==` operator so that equality of the resource means
equality of the `BOOL` member only, which is not ideal. I think that
an `is_invalid` member would do the trick rather nicely, however.
Also, I think that it would be nice to have a `shared_resource`
template. I have an application in mind where I would like to create a
shared `HANDLE` that is only closed if it is invalid and all
references to it have been destroyed (a shared reference count reaches
0).
> Hello!
>
> I have a small library that is intended for convenient and declarative
> resource wrappers creation.
>
> Read Documentation:
> http://rain.ifmo.ru/~sorokin/rcpp/doc/index.html
>
> Main Page:
> http://rain.ifmo.ru/~sorokin/rcpp/
>
> Although this library is small I think it is useful. I think it is
> possible to use it in implementations of asio, filesystem and thread.
>
> **--
> Ivan Sorokin
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk