renderbatch

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2026 License: MIT Imports: 2 Imported by: 0

Documentation

Overview

Package renderbatch implements per-device manager batching, not panel cadence. It holds revision handles only; the owner retains immutable complete targets.

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrPolicy   = errors.New("renderbatch: negative duration")
	ErrClock    = errors.New("renderbatch: negative or regressing monotonic clock")
	ErrRevision = errors.New("renderbatch: stale or invalid revision")
)

Functions

This section is empty.

Types

type Policy

type Policy struct {
	Debounce time.Duration
	MaxWait  time.Duration
}

Policy uses zero for omitted settings. MaxWait alone never introduces delay. Parse external durations with checked conversion; do not cast float seconds.

type Queue

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

Queue is single-owner. Serialize API edits before Submit, so a new revision represents the whole canonical scene, not an independently rendered patch. No goroutines, timers, frame copies, or unbounded history are owned here.

func New

func New(policy Policy) (*Queue, error)

func (*Queue) Release

func (q *Queue) Release(revision Revision) error

Release ends exactly the matching lease, without claiming display success or retrying it. The owner must reconcile failures/unknown ACKs before availability becomes true again. Confirmed frame/revision is deliberately not tracked here.

func (*Queue) Submit

func (q *Queue) Submit(revision Revision, now time.Duration) error

Submit replaces only pending work. Revisions never wrap within this queue; start a new coordinator epoch before exhaustion. Stale renders cannot submit.

func (*Queue) SubmitUrgent

func (q *Queue) SubmitUrgent(revision Revision, now time.Duration) error

SubmitUrgent bypasses grouping for this replacement only. It cannot bypass availability or the existing flight lease, and does not authorize refresh.

func (*Queue) Take

func (q *Queue) Take(now time.Duration, available bool) (Revision, error)

Take leases the newest ready revision. Availability includes transport, renderer readiness and device safety. MaxWait never overrides these gates. Zero means nothing can dispatch. New arrivals start a separate pending window.

func (*Queue) Wait

func (q *Queue) Wait(now time.Duration) (time.Duration, bool, error)

Wait returns the remaining grouping delay. False means no pending work. Caller can use a single timer and wake it on Submit, availability or Release. Elapsed-time subtraction avoids overflow when durations approach MaxInt64. Supply time.Since(serverStart), not Unix time, to preserve monotonic behavior: https://pkg.go.dev/time#hdr-Monotonic_Clocks

type Revision

type Revision uint64

Jump to

Keyboard shortcuts

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