Skip to content

Commit d6a1f8a

Browse files
committed
make SomeFuture public
1 parent c04576d commit d6a1f8a

File tree

1 file changed

+10
-1
lines changed

1 file changed

+10
-1
lines changed

chronos/internal/asyncfutures.nim

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ type
6060
FutureCompletedError* = object of FutureError
6161
## Error raised when trying access the error of a completed Future
6262

63-
SomeFuture = Future|InternalRaisesFuture
63+
SomeFuture* = Future|InternalRaisesFuture
6464

6565
func raiseFuturePendingError(fut: FutureBase) {.
6666
noinline, noreturn, raises: FuturePendingError.} =
@@ -1241,6 +1241,15 @@ proc one*[F: SomeFuture](futs: openArray[F]): Future[F] {.
12411241

12421242
oneImpl
12431243

1244+
proc oneCancel*[F: SomeFuture](futs: varargs[F]): Future[F] {.
1245+
async: (raw: true, raises: [ValueError, CancelledError]).} =
1246+
try:
1247+
await one(futs)
1248+
finally:
1249+
for f in futs:
1250+
if not f.completed:
1251+
await f.cancelAndWait()
1252+
12441253
template raceImpl =
12451254
# If one of the Future[T] already finished we return it as result
12461255
for fut in futs:

0 commit comments

Comments
 (0)