timer

package
v0.4.4 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Timer

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

The Timer module abstracts the passage of real time. It is used for implementing timeouts and periodic repetition.

func New

func New() *Timer

func (*Timer) ApplyEvents

func (tm *Timer) ApplyEvents(ctx context.Context, eventList *events.EventList) error

func (*Timer) Delay

func (tm *Timer) Delay(
	ctx context.Context,
	events *events.EventList,
	delay types.Duration,
)

Delay writes events to the output channel after delay. If context is canceled, no events might be written.

func (*Timer) EventsOut

func (tm *Timer) EventsOut() <-chan *events.EventList

func (*Timer) GarbageCollect

func (tm *Timer) GarbageCollect(retIndex tt.RetentionIndex)

GarbageCollect cancels the effect of outdated calls to Repeat. When GarbageCollect is called, the Timer stops repeatedly producing events associated with a retention index smaller than retIndex. If GarbageCollect already has been invoked with the same or higher retention index, the call has no effect.

func (*Timer) ImplementsModule

func (tm *Timer) ImplementsModule()

The ImplementsModule method only serves the purpose of indicating that this is a Module and must not be called.

func (*Timer) Repeat

func (tm *Timer) Repeat(
	ctx context.Context,
	events *events.EventList,
	period types.Duration,
	retIndex tt.RetentionIndex,
)

Repeat periodically writes events to the output channel with the given period. The repeated producing of events is associated with the retention index retIndex. The first write of events to the output channel happens immediately after invocation of Repeat. Repeat stops writing events to the output channel when 1) ctx is canceled or 2) GarbageCollect is called with an argument greater than the associated retIndex.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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