syncutil

package module
v0.0.0-...-5d4b1a7 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2022 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Future

type Future[T any] struct {
	// contains filtered or unexported fields
}

A Future holds a value that might not be available yet.

func NewFuture

func NewFuture[T any]() (f *Future[T], complete func(T))

NewFuture returns a new future and a function that completes that future with the given value. The returned complete function becomes a no-op after the first usage.

func (*Future[T]) Done

func (f *Future[T]) Done() <-chan struct{}

Done returns a channel that is closed when the future completes.

func (*Future[T]) Get

func (f *Future[T]) Get() T

Get blocks, if necessary, until the future is completed and then returns its value.

Jump to

Keyboard shortcuts

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