From 74e5ebaf4a3b42640eefff00ebba2a28297c0eb1 Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Tue, 31 Oct 2023 12:37:20 -0700 Subject: [PATCH] fix onFuturePause using template arg, not future object --- chronos/asyncfutures2.nim | 8 ++++---- chronos/asyncmacro2.nim | 8 ++++---- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/chronos/asyncfutures2.nim b/chronos/asyncfutures2.nim index 82ccd44..9f6533f 100644 --- a/chronos/asyncfutures2.nim +++ b/chronos/asyncfutures2.nim @@ -133,8 +133,8 @@ proc finish(fut: FutureBase, state: FutureState) = # 2. `fut.state` is checked by `checkFinished()`. fut.internalState = state when chronosFuturesInstrumentation: - if not(isNil(onFutureStop)): - onFutureStop(fut) + if not(isNil(futures.onFutureStop)): + futures.onFutureStop(fut) when chronosStrictFutureAccess: doAssert fut.internalCancelcb == nil or state != FutureState.Cancelled fut.internalCancelcb = nil # release cancellation callback memory @@ -320,8 +320,8 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} = template iterate = while true: when chronosFuturesInstrumentation: - if not(isNil(onFutureRunning)): - onFutureRunning(fut) + if not(isNil(futures.onFutureRunning)): + futures.onFutureRunning(fut) # Call closure to make progress on `fut` until it reaches `yield` (inside # `await` typically) or completes / fails / is cancelled next = fut.internalClosure(fut) diff --git a/chronos/asyncmacro2.nim b/chronos/asyncmacro2.nim index 2e0b56d..975d76a 100644 --- a/chronos/asyncmacro2.nim +++ b/chronos/asyncmacro2.nim @@ -299,8 +299,8 @@ template await*[T](f: Future[T]): untyped = chronosInternalRetFuture.internalChild = f when chronosFuturesInstrumentation: - if not(isNil(onFuturePause)): - onFuturePause(chronosInternalRetFuture, f) + if not(isNil(futures.onFuturePause)): + futures.onFuturePause(chronosInternalRetFuture, chronosInternalRetFuture.internalChild) # `futureContinue` calls the iterator generated by the `async` # transformation - `yield` gives control back to `futureContinue` which is @@ -323,8 +323,8 @@ template awaitne*[T](f: Future[T]): Future[T] = chronosInternalRetFuture.internalChild = f when chronosFuturesInstrumentation: - if not(isNil(onFuturePause)): - onFuturePause(chronosInternalRetFuture, f) + if not(isNil(futures.onFuturePause)): + futures.onFuturePause(chronosInternalRetFuture, chronosInternalRetFuture.internalChild) yield chronosInternalRetFuture.internalChild if chronosInternalRetFuture.internalMustCancel: