Help us shape the future of Go! Take the 2026 Go Developer Survey

queue

package
v0.1.1 Latest Latest
Warning

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

Go to latest
Published: Jul 30, 2025 License: BSD-3-Clause Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Job

type Job interface {
	ID() ids.ID
	Priority() uint64
	Execute() error
}

Job represents a job to be executed

type Jobs

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

Jobs tracks jobs that can be executed

func NewJobs

func NewJobs() *Jobs

NewJobs returns a new Jobs instance

func (*Jobs) Len

func (j *Jobs) Len() int

Len returns the number of jobs

func (*Jobs) Pop

func (j *Jobs) Pop() (Job, bool)

Pop removes and returns the highest priority job

func (*Jobs) Push

func (j *Jobs) Push(job Job)

Push adds a job

type JobsWithMissing

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

JobsWithMissing tracks jobs that are blocked on missing items

func NewJobsWithMissing

func NewJobsWithMissing() *JobsWithMissing

NewJobsWithMissing returns a new JobsWithMissing instance

func (*JobsWithMissing) AddMissingID

func (j *JobsWithMissing) AddMissingID(missingID ids.ID, job Job)

AddMissingID adds a job that's waiting for a missing ID

func (*JobsWithMissing) HasMissingIDs

func (j *JobsWithMissing) HasMissingIDs() bool

HasMissingIDs returns true if there are missing IDs

func (*JobsWithMissing) MissingIDs

func (j *JobsWithMissing) MissingIDs() []ids.ID

MissingIDs returns the IDs that are missing

func (*JobsWithMissing) RemoveMissingID

func (j *JobsWithMissing) RemoveMissingID(id ids.ID) []Job

RemoveMissingID removes jobs waiting for an ID and returns them

type Queue

type Queue interface {
	// Push adds a job to the queue
	Push(Job)

	// Pop removes and returns the highest priority job
	Pop() (Job, bool)

	// Len returns the number of jobs in the queue
	Len() int

	// Has returns true if the job is in the queue
	Has(ids.ID) bool

	// Remove removes a job from the queue
	Remove(ids.ID) bool
}

Queue is a priority queue for jobs

func NewQueue

func NewQueue() Queue

NewQueue returns a new job queue

Jump to

Keyboard shortcuts

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