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