Boost logo

Boost :

From: Greg Colvin (gcolvin_at_[hidden])
Date: 2002-01-28 05:15:43

From: "Thomas Maeder" <maeder_at_[hidden]>
> Am 2002.01.27 17:20 schrieb(en) Ross Smith:
> > > >
> > > > I don't understand why multiple ownership would make a difference.
> > >
> > > Who can decide when to close/flush?
> >
> > I still don't understand what you're driving at. Each piece of code
> > that uses the file flushes it when it's finished, obviously. What's
> > the
> > problem?
> Oh, now *I* see where *you* are driving at; I didn't get it before
> (maybe it's my English, or the flu).
> Your position depends on close() not failing if the file is flushed,
> which is wishful thinking IMHO unless documented so. But this may be a
> theoretical consideration, I don't know. Who does know?

It seems this is a general problem with resources whose release
operation can fail. Say you wrap the resource with an object whose
constructor acquires the resource and whose destructor releases it.
then either the destructor should recover from the failure -- by
waiting and retrying, logging and ignoring, or whatever -- or else
the precondition of the resource release function must be met before
calling the object. The problem remains no matter how you manage
the lifetime of the object, and is typically solved with some notion
of atomic transactions.

This is also related to the finalization problem in garbage collected

Boost list run by bdawes at, gregod at, cpdaniel at, john at