closer

package
Version: v0.0.0-...-06de07e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 19, 2019 License: MIT Imports: 1 Imported by: 4

Documentation

Overview

Emit a close function only once, also if called multiple times. This implementation is thread-safe.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Closer

type Closer struct {
	// Channel which is closed if the closer is closed.
	IsClosedChan chan struct{}
	// contains filtered or unexported fields
}

func New

func New(f func()) *Closer

New creates a new closer. The passed function is emitted only once, as soon close is called.

func (*Closer) Close

func (c *Closer) Close()

Close calls the function and sets the IsClosed boolean.

func (*Closer) IsClosed

func (c *Closer) IsClosed() bool

IsClosed returns a boolean whenever this closer is already closed.

Source Files

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL