serialqueue

package
v0.24.0 Latest Latest
Warning

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

Go to latest
Published: Nov 22, 2026 License: Apache-2.0 Imports: 3 Imported by: 0 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 serialqueue is the serial callback goroutine of the facade's `…Async` callbacks: a device's (device) and the node's own (node's OnDiagnosticEventAsync). One type, so both follow one rule.

Index

Constants

View Source
const Bound = 1024

Bound is the number of queued callbacks that have not started a queue holds; the one running is not counted.

Variables

This section is empty.

Functions

This section is empty.

Types

type Queue

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

Queue is a serial goroutine: the `…Async` callbacks run on it, one after the other, in the order they were enqueued. Its owner (ADR 0026 principle 5) starts it and stops it — waiting until every queued callback ran. Enqueue never blocks the goroutine that enqueues; a callback handed to a queue that is not running is dropped. The queue holds at most Bound callbacks that have not started: past it the oldest of them is dropped and counted (Queue.Dropped) and the first drop since the queue last ran empty is logged at warn (`matter.callbacks.dropped`); when the queue runs empty again the episode's count and the queue's total are logged at warn (`matter.callbacks.overflow_ended`), so a host callback slower than the events behind it costs those events, not unbounded memory. A callback must not stop its own queue's owner: the stop would wait for the callback that called it.

func New

func New() *Queue

New returns a queue that is not running.

func (*Queue) CountIn added in v0.11.0

func (q *Queue) CountIn(group func() *inflight.Group)

CountIn makes every callback enqueued from now on count as work of the group group returns at its Enqueue, until it returned: a fabrictest site does not move its clock while a host callback waits or runs. group may return nil (no group: nothing is counted).

func (*Queue) Dropped

func (q *Queue) Dropped() uint64

Dropped is the number of callbacks dropped at Bound since New.

func (*Queue) Enqueue

func (q *Queue) Enqueue(fn func())

Enqueue queues fn; a no-op for nil or while the queue does not run.

func (*Queue) Len

func (q *Queue) Len() int

Len is the number of queued callbacks that have not started.

func (*Queue) SetLogger

func (q *Queue) SetLogger(l *slog.Logger)

SetLogger sets the logger of the queue's warnings; nil logs through slog.Default().

func (*Queue) Start

func (q *Queue) Start()

Start runs the queue's goroutine; a no-op while it runs.

func (*Queue) Stop

func (q *Queue) Stop()

Stop ends the goroutine once it ran every queued callback and waits for it; a no-op when it does not run.

Jump to

Keyboard shortcuts

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