Documentation ¶
Index ¶
- type Awaitable
- type AwaitableBase
- func (awaitable AwaitableBase) After(timeout time.Duration) Awaitable
- func (awaitable *AwaitableBase) Channel() <-chan Void
- func (awaitable AwaitableBase) Next(action func()) Awaitable
- func (awaitable *AwaitableBase) Peek() bool
- func (awaitable *AwaitableBase) Wait(timeout time.Duration) bool
- func (awaitable *AwaitableBase) WaitForever()
- func (awaitable *AwaitableBase) WaitTimer(timerC <-chan time.Time) bool
- type SignalAwaitable
- type Void
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Awaitable ¶
type Awaitable interface { After(timeout time.Duration) Awaitable Channel() <-chan Void Next(action func()) Awaitable Peek() bool Wait(timeout time.Duration) bool WaitForever() WaitTimer(timerC <-chan time.Time) bool }
Awaitable is a signal that can waited on.
func AllAwaitables ¶
AllAwaitables creates an aggregated Awaitable waiting for all of the given Awaitable(s)
func AnyAwaitables ¶
AnyAwaitables creates an aggregated Awaitable waiting for any of the given Awaitable(s)
func NewWaitGroupAwaitable ¶
NewWaitGroupAwaitable creates an Awaitable waiting on the given sync.WaitGroup The waiting on the given WaitGroup starts immediately in this call and ends when the counter reaches zero. Subsequent changing of the counter would have no effect - a new Awaitable would need to be created.
type AwaitableBase ¶
type AwaitableBase struct {
// contains filtered or unexported fields
}
AwaitableBase provides waiting methods by a channel (to be closed)
func (AwaitableBase) After ¶
func (awaitable AwaitableBase) After(timeout time.Duration) Awaitable
After creates an awaitable which is signaled after this awaitable and certain duration of time It returns a chained Awaitable; The current Awaitable can still be waited on.
func (*AwaitableBase) Channel ¶
func (awaitable *AwaitableBase) Channel() <-chan Void
Channel returns the internal channel that can be used in more complex situations. The returned channel is meant to be read-only and select should either be pending or not-ok, because the signal is done by closing the channel, not by sending any message.
func (AwaitableBase) Next ¶
func (awaitable AwaitableBase) Next(action func()) Awaitable
Next chains an action to be executed when the current Awaitable is done/signaled (no timeout) It returns a chained Awaitable; The current Awaitable can still be waited on.
func (*AwaitableBase) Peek ¶
func (awaitable *AwaitableBase) Peek() bool
Peek returns true if the signal has come. It doesn't wait.
func (*AwaitableBase) Wait ¶
func (awaitable *AwaitableBase) Wait(timeout time.Duration) bool
Wait waits for the signal until specified timeout. Returns true if sucessful or false if timeout
func (*AwaitableBase) WaitForever ¶
func (awaitable *AwaitableBase) WaitForever()
WaitForever waits for the signal
type SignalAwaitable ¶
type SignalAwaitable struct {
AwaitableBase
}
SignalAwaitable is a one-time signal that can waited on. It's implemented by a simple channel without any message
func NewSignalAwaitable ¶
func NewSignalAwaitable() *SignalAwaitable
NewSignalAwaitable creates a SignalAwaitable / one-time signal to be waited on.
func (*SignalAwaitable) Signal ¶
func (awaitable *SignalAwaitable) Signal()
Signal marks the Awaitable to notify the awaiter(s) It can be only called once or panic