fix onFuturePause using template arg, not future object

This commit is contained in:
Jaremy Creechley 2023-10-31 12:37:20 -07:00
parent 0a14f702ee
commit 74e5ebaf4a
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 8 additions and 8 deletions

View File

@ -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)

View File

@ -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: