@@ -39,6 +39,13 @@ func MustAll(awaitables ...*task.Task) []interface{} {
39
39
return v
40
40
}
41
41
42
+ // AllAsync does the same thing as All but does so asynchronously
43
+ func AllAsync (awaitables ... * task.Task ) * task.Task {
44
+ return task .New (func (t * task.Internal ) {
45
+ t .Resolve (MustAll (awaitables ... ))
46
+ })
47
+ }
48
+
42
49
// AllOrError will wait for every given task to emit a result or
43
50
// return as soon as an error is encountered, stopping all other tasks.
44
51
func AllOrError (awaitables ... * task.Task ) ([]interface {}, error ) {
@@ -88,6 +95,13 @@ func MustAllOrError(awaitables ...*task.Task) []interface{} {
88
95
return v
89
96
}
90
97
98
+ // AllOrErrorAsync does the same thing as AllOrError but does so asynchronously
99
+ func AllOrErrorAsync (awaitables ... * task.Task ) * task.Task {
100
+ return task .New (func (t * task.Internal ) {
101
+ t .Resolve (MustAllOrError (awaitables ... ))
102
+ })
103
+ }
104
+
91
105
// AllOrErrorWithTimeout does the same as AllOrError but allows you to set a
92
106
// timeout for waiting for other tasks to stop.
93
107
func AllOrErrorWithTimeout (timeout time.Duration , awaitables ... * task.Task ) ([]interface {}, error ) {
@@ -137,6 +151,13 @@ func MustAllOrErrorWithTimeout(timeout time.Duration, awaitables ...*task.Task)
137
151
return v
138
152
}
139
153
154
+ // AllOrErrorWithTimeoutAsync does the same thing as AllOrErrorWithTimeout but does so asynchronously
155
+ func AllOrErrorWithTimeoutAsync (timeout time.Duration , awaitables ... * task.Task ) * task.Task {
156
+ return task .New (func (t * task.Internal ) {
157
+ t .Resolve (MustAllOrErrorWithTimeout (timeout , awaitables ... ))
158
+ })
159
+ }
160
+
140
161
// FastAllOrError does the same as AllOrError but does not wait for all other
141
162
// tasks to stop, it does tell them to stop it just doesn't wait for them to stop.
142
163
func FastAllOrError (awaitables ... * task.Task ) ([]interface {}, error ) {
@@ -186,6 +207,13 @@ func MustFastAllOrError(awaitables ...*task.Task) []interface{} {
186
207
return v
187
208
}
188
209
210
+ // FastAllOrErrorAsync does the same thing as FastAllOrError but does so asynchronously
211
+ func FastAllOrErrorAsync (awaitables ... * task.Task ) * task.Task {
212
+ return task .New (func (t * task.Internal ) {
213
+ t .Resolve (MustFastAllOrError (awaitables ... ))
214
+ })
215
+ }
216
+
189
217
// Any will wait for the first task to emit a result (or an error)
190
218
// and return that, stopping all other tasks.
191
219
func Any (awaitables ... * task.Task ) (interface {}, error ) {
@@ -220,6 +248,13 @@ func MustAny(awaitables ...*task.Task) interface{} {
220
248
return v
221
249
}
222
250
251
+ // AnyAsync does the same thing as Any but does so asynchronously
252
+ func AnyAsync (awaitables ... * task.Task ) * task.Task {
253
+ return task .New (func (t * task.Internal ) {
254
+ t .Resolve (MustAny (awaitables ... ))
255
+ })
256
+ }
257
+
223
258
// AnyWithTimeout does the same as Any but allows you to set a
224
259
// timeout for waiting for other tasks to stop.
225
260
func AnyWithTimeout (timeout time.Duration , awaitables ... * task.Task ) (interface {}, error ) {
@@ -254,6 +289,13 @@ func MustAnyWithTimeout(timeout time.Duration, awaitables ...*task.Task) interfa
254
289
return v
255
290
}
256
291
292
+ // AnyWithTimeoutAsync does the same thing as AnyWithTimeout but does so asynchronously
293
+ func AnyWithTimeoutAsync (timeout time.Duration , awaitables ... * task.Task ) * task.Task {
294
+ return task .New (func (t * task.Internal ) {
295
+ t .Resolve (MustAnyWithTimeout (timeout , awaitables ... ))
296
+ })
297
+ }
298
+
257
299
// FastAny does the same as Any but does not wait for all other tasks to stop,
258
300
// it does tell them to stop it just doesn't wait for them to stop.
259
301
func FastAny (awaitables ... * task.Task ) (interface {}, error ) {
@@ -288,6 +330,13 @@ func MustFastAny(awaitables ...*task.Task) interface{} {
288
330
return v
289
331
}
290
332
333
+ // FastAnyAsync does the same thing as FastAny but does so asynchronously
334
+ func FastAnyAsync (awaitables ... * task.Task ) * task.Task {
335
+ return task .New (func (t * task.Internal ) {
336
+ t .Resolve (MustFastAny (awaitables ... ))
337
+ })
338
+ }
339
+
291
340
// ErrTaskFailed is returned by the All methods when at least one task returns an error.
292
341
type ErrTaskFailed struct {
293
342
Errors []error
0 commit comments