candidatecache

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Jul 5, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package candidatecache holds the per-replica bounded set of step candidates produced by the engine's refiller. It is a hint cache, not a work queue: entries confer no ownership, so a stale or duplicated candidate is harmless. The engine claims the underlying step via CAS before running it.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cache

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

Cache is a bounded per-replica set of step candidates - hints, not ownership.

func (*Cache) Capacity

func (c *Cache) Capacity() int

Capacity returns the cache's bound (twice the worker count).

func (*Cache) Close

func (c *Cache) Close()

Close permanently unblocks all waiters. Offer/Refill become no-ops after close.

func (*Cache) Init

func (c *Cache) Init(workers int)

Init sizes the cache to twice the worker count and resets it for reuse.

func (*Cache) Len

func (c *Cache) Len() int

Len returns the number of buffered candidates.

func (*Cache) Offer

func (c *Cache) Offer(j Job, priority int) (needRefill bool)

Offer front-loads a single higher-priority candidate. It returns needRefill=true when the cache is empty (the caller should refill); a candidate whose priority is no better than the current floor is dropped.

func (*Cache) Pop

func (c *Cache) Pop() (j Job, ok bool, needRefill bool)

Pop removes and returns the front candidate, blocking until one is available or the cache closes. needRefill signals that the cache has drained to its low-water mark so draining overlaps refill.

func (*Cache) Refill

func (c *Cache) Refill(batch []Job, floor int)

Refill replaces the cache contents with batch at the given priority floor and wakes all waiters.

type Job

type Job struct {
	StepID int
	Shard  int
}

Job holds a step ID and its shard index for the worker pool.

Jump to

Keyboard shortcuts

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