scheduler

package
v1.12.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2023 License: MIT Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Handle

type Handle interface {
	// Get attempts to acquire a Resource. It will return nil and false if
	// the handle is already Done or if the context is canceled before the
	// resource is acquired. It should not be called concurrently with Done.
	Get(context.Context) (Resource, bool)

	// Done signals that no more resources should be acquired with Get, and
	// it waits for existing resources to be done. It should not be called
	// concurrently with Get.
	Done()
}

Handle is the interface describing acquired handles from a scheduler.

type Options

type Options struct {
	MaximumConcurrent        int // number of maximum concurrent resources
	MaximumConcurrentHandles int // number of maximum concurrent handles
}

Options controls the parameters of the Scheduler.

type Resource

type Resource interface {
	// Done signals that the resource is no longer in use and must be called
	// exactly once.
	Done()
}

Resource is the interface describing acquired resources from a scheduler.

type Scheduler

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

Scheduler is a type to regulate a number of resources held by handles with the property that earlier acquired handles get preference for new resources over later acquired handles.

func New

func New(opts Options) *Scheduler

New constructs a new Scheduler.

func (*Scheduler) Join

func (s *Scheduler) Join(ctx context.Context) (Handle, bool)

Join acquires a new Handle that can be used to acquire Resources.

Jump to

Keyboard shortcuts

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