syncutil

package
v0.9.8 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 2026 License: MIT Imports: 2 Imported by: ? modules, 0 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 syncutil holds synchronization helpers the standard library lacks.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Loop added in v0.9.1

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

Loop is the goroutine that takes new work, one per Start. Stop cancels it and waits for it to return, with no deadline, so two starts never run it at once: run returns as soon as its ctx ends, and hands anything slow to a WaitGroup, which Stop waits for only as long as its own ctx allows. Start and Stop are the caller's to serialize, as the supervisor does.

func (*Loop) Running added in v0.9.1

func (l *Loop) Running() bool

Running is true from Start to Stop, whether or not run has returned on its own.

func (*Loop) Start added in v0.9.1

func (l *Loop) Start(ctx context.Context, run func(ctx context.Context)) bool

Start runs run in a goroutine, under a context of its own that keeps ctx's values, never its cancel or deadline, so Stop alone ends the loop; false, running nothing, if a loop runs already.

func (*Loop) Stop added in v0.9.1

func (l *Loop) Stop() bool

Stop cancels the loop and returns once it has; false if none was started.

type WaitGroup

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

WaitGroup is a sync.WaitGroup whose Wait honours ctx and whose Add is legal at any time.

func (*WaitGroup) Add

func (g *WaitGroup) Add(delta int)

func (*WaitGroup) Done

func (g *WaitGroup) Done()

func (*WaitGroup) Go

func (g *WaitGroup) Go(f func())

func (*WaitGroup) Wait

func (g *WaitGroup) Wait(ctx context.Context) error

Jump to

Keyboard shortcuts

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