mirror of
https://github.com/logos-storage/nim-chronos.git
synced 2026-01-09 08:53:08 +00:00
fix onFuturePause using template arg, not future object
This commit is contained in:
parent
0a14f702ee
commit
74e5ebaf4a
@ -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)
|
||||
|
||||
@ -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:
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user