Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Future ¶
type Future[R any] interface { Wait() R }
Future represents a computation that will produce a result of type R in the future. The result can be retrieved by calling the Wait method, which blocks until the computation is complete.
func RaceAll ¶
RaceAll takes multiple Future instances and returns a new Future that resolves to the result of the first Future to complete. The remaining Future computations are not canceled and will continue to execute in the background.
func Start ¶
Start begins a computation that runs the provided function fn in a separate goroutine. The computation's result of type R can be retrieved by calling the Wait method on the returned Future. The provided ctx is passed to the function fn to support context-aware operations.
func Value ¶
Value creates a Future that immediately resolves to the provided value. The computation runs in a separate goroutine and can be awaited using the Wait method.
func WaitAll ¶
WaitAll takes multiple Future instances and returns a new Future that resolves to a slice of results once all the provided Future instances have completed. The results are returned in the same order as the input Future instances.
func WaitMap ¶ added in v0.4.0
func WaitMap[K comparable, R any](m map[K]Future[R]) Future[map[K]R]
WaitMap takes a map of Future instances and returns a new Future that resolves to a map containing the results of all the provided Future instances. The keys in the resulting map correspond to the keys in the input map, and the values are the results of the respective Future computations.