base: Index | Files

package once

import ""

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


Package Files


type Map Uses

type Map sync.Map

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

func (*Map) Do Uses

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 Uses

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

Forget forgets past computations associated with the provided key.

type Task Uses

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 Uses

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.

Package once imports 2 packages (graph) and is imported by 9 packages. Updated 2018-11-29. Refresh now. Tools for package owners.