signal

package
v3.11.2+incompatible Latest Latest
Warning

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

Go to latest
Published: Mar 4, 2018 License: MIT Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ErrorOrFinish1

func ErrorOrFinish1(ctx context.Context, c <-chan error) error

func ErrorOrFinish2

func ErrorOrFinish2(ctx context.Context, c1, c2 <-chan error) error

func ExecuteAsync

func ExecuteAsync(f func() error) <-chan error

ExecuteAsync executes a function asychrously and return its result.

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 an 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 mutliple 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 an utility for notifying changes. The change producer may notify changes multiple time, and the consumer may get notified asychronously.

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
	// contains filtered or unexported fields
}

PeriodicTask is a task that runs periodically.

func (*PeriodicTask) Close

func (t *PeriodicTask) Close() error

Close implements common.Runnable.

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
}

func NewSemaphore

func NewSemaphore(n int) *Semaphore

func (*Semaphore) Signal

func (s *Semaphore) Signal()

func (*Semaphore) Wait

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

Jump to

Keyboard shortcuts

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