From d6a1f8a98b7a1bc133e9d08d796141dffd9a5f7c Mon Sep 17 00:00:00 2001 From: Diego Date: Thu, 29 Aug 2024 22:17:35 +0200 Subject: [PATCH] make SomeFuture public --- chronos/internal/asyncfutures.nim | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/chronos/internal/asyncfutures.nim b/chronos/internal/asyncfutures.nim index 6c8f2bdd..7c1cf0f1 100644 --- a/chronos/internal/asyncfutures.nim +++ b/chronos/internal/asyncfutures.nim @@ -60,7 +60,7 @@ type FutureCompletedError* = object of FutureError ## Error raised when trying access the error of a completed Future - SomeFuture = Future|InternalRaisesFuture + SomeFuture* = Future|InternalRaisesFuture func raiseFuturePendingError(fut: FutureBase) {. noinline, noreturn, raises: FuturePendingError.} = @@ -1241,6 +1241,15 @@ proc one*[F: SomeFuture](futs: openArray[F]): Future[F] {. oneImpl +proc oneCancel*[F: SomeFuture](futs: varargs[F]): Future[F] {. + async: (raw: true, raises: [ValueError, CancelledError]).} = + try: + await one(futs) + finally: + for f in futs: + if not f.completed: + await f.cancelAndWait() + template raceImpl = # If one of the Future[T] already finished we return it as result for fut in futs: