Documentation ¶
Overview ¶
Package kdone provides tools for destroying objects.
Index ¶
- Variables
- type CloserFunc
- type Destructor
- type DestructorFunc
- type Reaper
- func (r *Reaper) Assume(dtor Destructor) error
- func (r *Reaper) Finalize() error
- func (r *Reaper) Finalized() bool
- func (r *Reaper) MustAssume(dtor Destructor)
- func (r *Reaper) MustFinalize()
- func (r *Reaper) MustRelease() Destructor
- func (r *Reaper) Release() (Destructor, error)
- func (r *Reaper) Released() bool
Constants ¶
This section is empty.
Variables ¶
var Noop = DestructorFunc(func() error { return nil })
Noop specifies the destructor that does nothing.
Functions ¶
This section is empty.
Types ¶
type CloserFunc ¶ added in v0.1.1
type CloserFunc func() error
CloserFunc represents a functional implementation of the io.Closer interface.
func (CloserFunc) Close ¶ added in v0.1.1
func (f CloserFunc) Close() error
Close implements the io.Closer interface.
type Destructor ¶
type Destructor interface { // DestroyStack destroys an associated object. Destroy() error // MustDestroy is a variant of the Destroy that panics on error. MustDestroy() }
Destructor represents an object destructor.
The usual identifier for variables of this type is dtor.
type DestructorFunc ¶
type DestructorFunc func() error
DestructorFunc represents a functional implementation of the Destructor interface.
func (DestructorFunc) Destroy ¶
func (f DestructorFunc) Destroy() error
Destroy implements the Destructor interface.
func (DestructorFunc) MustDestroy ¶
func (f DestructorFunc) MustDestroy()
MustDestroy implements the Destructor interface.
type Reaper ¶
type Reaper struct {
// contains filtered or unexported fields
}
Reaper represents a mechanism of deferred call of destructors.
func (*Reaper) Assume ¶
func (r *Reaper) Assume(dtor Destructor) error
Assume passes the responsibility for calling the given destructor to this reaper.
func (*Reaper) Finalize ¶
Finalize calls destructors in the backward order if this reaper was not released from this responsibility yet.
func (*Reaper) Finalized ¶ added in v0.2.6
Finalized returns boolean specifies whether did this reapers call destructors.
func (*Reaper) MustAssume ¶
func (r *Reaper) MustAssume(dtor Destructor)
MustAssume is a variant of the Assume that panics on error.
func (*Reaper) MustFinalize ¶
func (r *Reaper) MustFinalize()
MustFinalize is a variant of the Finalize that panics on error.
func (*Reaper) MustRelease ¶
func (r *Reaper) MustRelease() Destructor
MustRelease is a variant of the Release that panics on error.
func (*Reaper) Release ¶
func (r *Reaper) Release() (Destructor, error)
Release releases this reaper from the responsibility for calling destructors and pass it to caller by return a composite destructor that calls destructors in the backward order.