xsync

package
v0.19.19 Latest Latest
Warning

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

Go to latest
Published: Dec 17, 2025 License: MIT Imports: 3 Imported by: 0

Documentation

Overview

Package xsync provides synchronization utilities. It is an extension to the standard sync package.

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
}

Future is a container for a value that may not yet be available.

func (*Future[T]) Load

func (a *Future[T]) Load() (T, bool)

Load returns the value stored in the Future, if it is ready.

func (*Future[T]) Ready

func (a *Future[T]) Ready() <-chan struct{}

Ready returns a channel that is closed when the value becomes available.

func (*Future[T]) Store

func (a *Future[T]) Store(v T) bool

Store sets the value of the Future.

It returns false if the value was already set.

func (*Future[T]) Wait

func (a *Future[T]) Wait(ctx context.Context) (T, error)

Wait blocks until the value becomes available or the context is canceled.

type SucceedOnce

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

SucceedOnce is a sync.Once variant that allows for the operation to fail.

func (*SucceedOnce) Do

func (o *SucceedOnce) Do(
	ctx context.Context,
	fn func(ctx context.Context) error,
) error

Do executes the fn if and only if it has not been called successfully before.

Jump to

Keyboard shortcuts

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