closer

package
v0.0.0-...-92da4da Latest Latest
Warning

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

Go to latest
Published: Apr 12, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Closer

type Closer interface {
	Start(ctx context.Context) context.Context
	Done()
	Close() error
}

A Closer allows you to close goroutines spawned by the owner via a derived cancellable context.

Basic example:

var owner.closer = NewCloser()
func (o *owner) startWork(ctx context.Context) {
	ctx = o.closer.Start(ctx)
	go func() {
		doWork(ctx)
		s.closer.Done()
	}
}
func (o *owner) Close() error {
	return o.closer.Close()
}

func NewCloser

func NewCloser() Closer

Jump to

Keyboard shortcuts

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