Documentation ¶
Overview ¶
Package future Most of the code here has been copied from (https://github.com/Workiva/go-datastructures) with a slight modification
Index ¶
Constants ¶
This section is empty.
Variables ¶
var ErrTimeout = func(duration time.Duration) error { return fmt.Errorf(`timeout after %f seconds`, duration.Seconds()) }
ErrTimeout is returned when the future has timed out
Functions ¶
This section is empty.
Types ¶
type Future ¶
type Future struct {
// contains filtered or unexported fields
}
Future represents an object that can be used to perform asynchronous tasks. The constructor of the future will complete it, and listeners will block on Result until a result is received. This is different from a channel in that the future is only completed once, and anyone listening on the future will get the result, regardless of the number of listeners.
func NewWithContext ¶
NewWithContext creates an instance of Future with a context. The future will time out when the given context is canceled before the response is received