Documentation ¶
Overview ¶
Package futureevent defines interface to handle future events.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Event ¶
type Event interface { // Chan returns a channel which this Event notifies of the occurrence. // The time.Time value represents the time of the occurrence. // // Remember that the event may be canceled, in which case the channel // gets closed and empty. The listeners can detect the cancelation by // checking the boolean result of a receive operation. Chan() <-chan time.Time // Cancel cancels the event. // // Cancel clears and closes the event notifier channel, thus must not be // called more than once. Cancel() }
Event represents a cancelable event that occurs sometime in future.
func NewRealClockEvent ¶
NewRealClockEvent returns a new Event kicked at the provided Time, using the real clock.
type Factory ¶
Factory creates a new Event raised when the provided time t comes.
var DefaultFactory Factory = NewRealClockEvent
DefaultFactory uses the real clock.
type NeverOccursEvent ¶
type NeverOccursEvent struct {
// contains filtered or unexported fields
}
NeverOccursEvent never occurs. It is still cancelable.
func (*NeverOccursEvent) Cancel ¶
func (e *NeverOccursEvent) Cancel()
Cancel unblocks the receive operation on e.Chan().
func (*NeverOccursEvent) Chan ¶
func (e *NeverOccursEvent) Chan() <-chan time.Time
Chan returns an event notifier channel. Since the event never occurs, the receive operation on the returned channel would be blocked until e is canceled.
type TriggerableEvent ¶
type TriggerableEvent struct {
// contains filtered or unexported fields
}
TriggerableEvent is an Event triggered by a method call.
func NewTriggerableEvent ¶
func NewTriggerableEvent() *TriggerableEvent
NewTriggerableEvent creates a new TriggerableEvent.
func (*TriggerableEvent) Cancel ¶
func (e *TriggerableEvent) Cancel()
Cancel makes e no longer triggerable.
func (*TriggerableEvent) Chan ¶
func (e *TriggerableEvent) Chan() <-chan time.Time
Chan returns the event notifier channel.