|
Boost : |
Subject: Re: [boost] [outcome] Exception safety guarantees
From: Niall Douglas (s_sourceforge_at_[hidden])
Date: 2017-05-30 13:39:27
On 30/05/2017 07:36, Vicente J. Botet Escriba via Boost wrote:
> Le 30/05/2017 à 04:13, Emil Dotchevski via Boost a écrit :
>> On Mon, May 29, 2017 at 12:50 AM, Andrzej Krzemienski via Boost <
>> Why is it better to use shared_ptr instead of move-only wrappers when
>> dealing with (file) handles? Because handles are copyable types and (by
>> design) they can be shared.
>
> I would say that it depends on the application, we need movable and
> shared handles. BTW, I don't know what (std| boost) Filesystem provides?
A useful data point to this discussion might be that in the AFIO v1
review, many objected to the default use of reference counting file
handles via shared_ptr.
That design choice was made because file handles are such a precious
resource on many systems, so the more sharing and reuse we could
automate, the better.
But I was persuaded during the AFIO v1 review that end users could wrap
up an afio::file_handle into a shared_ptr on their own, and implement
whatever file handle conservation techniques they liked on their own.
Hence AFIO v2 implements a very stupid afio::file_handle with move only
semantics. It provides a .clone() function to make a copy, this is
because duplicating file handles is very slow on some systems, or else
there is a very low limit to the number which can exist at once.
Niall
-- ned Productions Limited Consulting http://www.nedproductions.biz/ http://ie.linkedin.com/in/nialldouglas/
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk