once

package
v0.0.1-really Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: Apache-2.0 Imports: 2 Imported by: 6 modules, 10 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package once contains utilities for managing actions that must be performed exactly once.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Map

type Map sync.Map

Map coordinates actions that must happen exactly once, keyed by user-defined keys.

func (*Map) Do

func (m *Map) Do(key interface{}, do func() error) error

Perform the provided action named by a key. Do invokes the action exactly once for each key, and returns any errors produced by the provided action.

func (*Map) Forget

func (m *Map) Forget(key interface{})

Forget forgets past computations associated with the provided key.

type Task

type Task struct {
	// contains filtered or unexported fields
}

Task manages a computation that must be run at most once. It's similar to sync.Once, except it also handles and returns errors.

func (*Task) Do

func (o *Task) Do(do func() error) error

Do run the function do at most once. Successive invocations of Do guarantee exactly one invocation of the function do. Do returns the error of do's invocation.

Jump to

Keyboard shortcuts

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