signal

package
v3.18.1+incompatible Latest Latest
Warning

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

Go to latest
Published: Apr 14, 2018 License: MIT Imports: 3 Imported by: 7

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Execute

func Execute(tasks ...func() error) error

Execute runs a list of tasks sequentially, returns the first error encountered or nil if all tasks pass.

func ExecuteParallel

func ExecuteParallel(ctx context.Context, tasks ...func() error) error

ExecuteParallel executes a list of tasks asynchronously, returns the first error encountered or nil if all tasks pass.

Types

type ActivityTimer

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

func CancelAfterInactivity

func CancelAfterInactivity(ctx context.Context, cancel context.CancelFunc, timeout time.Duration) *ActivityTimer

func (*ActivityTimer) SetTimeout

func (t *ActivityTimer) SetTimeout(timeout time.Duration)

func (*ActivityTimer) Update

func (t *ActivityTimer) Update()

type ActivityUpdater

type ActivityUpdater interface {
	Update()
}

type Done

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

Done is a utility for notifications of something being done.

func NewDone

func NewDone() *Done

NewDone returns a new Done.

func (*Done) C

func (d *Done) C() chan struct{}

C returns a channel for waiting for done.

func (*Done) Close

func (d *Done) Close() error

Close marks this Done 'done'. This method may be called multiple times. All calls after first call will have no effect on its status.

func (*Done) Done

func (d *Done) Done() bool

Done returns true if Close() is called.

func (*Done) Wait

func (d *Done) Wait()

Wait blocks until Close() is called.

type Notifier

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

Notifier is a utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asynchronously.

func NewNotifier

func NewNotifier() *Notifier

NewNotifier creates a new Notifier.

func (*Notifier) Signal

func (n *Notifier) Signal()

Signal signals a change, usually by producer. This method never blocks.

func (*Notifier) Wait

func (n *Notifier) Wait() <-chan struct{}

Wait returns a channel for waiting for changes. The returned channel never gets closed.

type PeriodicTask

type PeriodicTask struct {
	// Interval of the task being run
	Interval time.Duration
	// Execute is the task function
	Execute func() error
	// OnFailure will be called when Execute returns non-nil error
	OnError func(error)
	// contains filtered or unexported fields
}

PeriodicTask is a task that runs periodically.

func (*PeriodicTask) Close

func (t *PeriodicTask) Close() error

Close implements common.Closable.

func (*PeriodicTask) Start

func (t *PeriodicTask) Start() error

Start implements common.Runnable. Start must not be called multiple times without Close being called.

type Semaphore

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

Semaphore is an implementation of semaphore.

func NewSemaphore

func NewSemaphore(n int) *Semaphore

NewSemaphore create a new Semaphore with n permits.

func (*Semaphore) Signal

func (s *Semaphore) Signal()

Signal releases a permit into the Semaphore.

func (*Semaphore) Wait

func (s *Semaphore) Wait() <-chan struct{}

Wait returns a channel for acquiring a permit.

Jump to

Keyboard shortcuts

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