mirror of
https://github.com/logos-storage/nim-chronos.git
synced 2026-01-03 22:13:06 +00:00
move instrumentation points for async future FSM into more correct locations
This commit is contained in:
parent
3f774a1fa4
commit
5d27b12b17
@ -315,11 +315,11 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} =
|
||||
# instead with its original body captured in `fut.closure`.
|
||||
var next: FutureBase
|
||||
template iterate =
|
||||
while true:
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureExecEvent):
|
||||
onFutureExecEvent(fut, Running)
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureExecEvent):
|
||||
onFutureExecEvent(fut, Running)
|
||||
|
||||
while true:
|
||||
# Call closure to make progress on `fut` until it reaches `yield` (inside
|
||||
# `await` typically) or completes / fails / is cancelled
|
||||
next = fut.internalClosure(fut)
|
||||
@ -327,11 +327,6 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} =
|
||||
if fut.internalClosure.finished(): # Reached the end of the transformed proc
|
||||
break
|
||||
|
||||
# If we got thus far, means the future is paused.
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureExecEvent):
|
||||
onFutureExecEvent(fut, Paused)
|
||||
|
||||
if next == nil:
|
||||
raiseAssert "Async procedure (" & ($fut.location[LocationKind.Create]) &
|
||||
") yielded `nil`, are you await'ing a `nil` Future?"
|
||||
@ -342,6 +337,10 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} =
|
||||
GC_ref(fut)
|
||||
next.addCallback(CallbackFunc(internalContinue), cast[pointer](fut))
|
||||
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureExecEvent):
|
||||
onFutureExecEvent(fut, Paused)
|
||||
|
||||
# return here so that we don't remove the closure below
|
||||
return
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user