effectqueue

package
v0.9.0-dev.18 Latest Latest
Warning

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

Go to latest
Published: Oct 16, 2026 License: AGPL-3.0 Imports: 1 Imported by: 0

Documentation

Overview

Package effectqueue runs the side effects a mutation decided under a state lock after that lock is released, in the order the mutations happened.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue orders effect batches. Add batches in mutation order, either under the lock that orders the mutations or from one goroutine at a time that takes them in that order, and call Drain after releasing that lock. One goroutine drains at a time: a Drain that finds another in progress returns at once and leaves its batch to that goroutine, so an effect can run after its own caller returned, but never before an effect added ahead of it. The zero Queue is ready to use.

func (*Queue) Add

func (q *Queue) Add(fns ...func())

Add appends fns to the queue.

func (*Queue) Drain

func (q *Queue) Drain()

Drain runs every queued effect, including those added while it runs, unless another goroutine is already draining. An effect that panics stops the drain and leaves the effects after it queued for the next one.

Jump to

Keyboard shortcuts

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