mirror of
https://github.com/logos-storage/nim-chronos.git
synced 2026-01-04 22:43:07 +00:00
import tests
This commit is contained in:
parent
77dfb0d576
commit
48abae1fff
@ -99,12 +99,11 @@ when chronosFutureTracking:
|
||||
var futureList* {.threadvar.}: FutureList
|
||||
|
||||
when chronosProfiling:
|
||||
type FutureExecutionEvent* {.pure.} = enum
|
||||
type FutureEvent* {.pure.} = enum
|
||||
Init, Run, Pause, Finish
|
||||
|
||||
var onFutureEvent* {.threadvar.}:
|
||||
proc (fut: FutureBase,
|
||||
state: FutureExecutionEvent): void {.nimcall, gcsafe, raises: [].}
|
||||
proc (fut: FutureBase, state: FutureEvent): void {.nimcall, gcsafe, raises: [].}
|
||||
|
||||
# Internal utilities - these are not part of the stable API
|
||||
proc internalInitFutureBase*(fut: FutureBase, loc: ptr SrcLoc,
|
||||
|
||||
@ -195,7 +195,7 @@ proc finish(fut: FutureBase, state: FutureState) =
|
||||
fut.internalCancelcb = nil # release cancellation callback memory
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureEvent):
|
||||
onFutureEvent(fut, Finish)
|
||||
onFutureEvent(fut, FutureEvent.Finish)
|
||||
for item in fut.internalCallbacks.mitems():
|
||||
if not(isNil(item.function)):
|
||||
callSoon(item)
|
||||
@ -377,8 +377,8 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} =
|
||||
# instead with its original body captured in `fut.closure`.
|
||||
while true:
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureExecEvent):
|
||||
onFutureEvent(fut, Run)
|
||||
if not isNil(onFutureEvent):
|
||||
onFutureEvent(fut, FutureEvent.Run)
|
||||
# Call closure to make progress on `fut` until it reaches `yield` (inside
|
||||
# `await` typically) or completes / fails / is cancelled
|
||||
let next: FutureBase = fut.internalClosure(fut)
|
||||
@ -397,8 +397,8 @@ proc futureContinue*(fut: FutureBase) {.raises: [], gcsafe.} =
|
||||
|
||||
# If we got thus far, means the future is paused.
|
||||
when chronosProfiling:
|
||||
if not isNil(onFutureExecEvent):
|
||||
onFutureEvent(fut, Pause)
|
||||
if not isNil(onFutureEvent):
|
||||
onFutureEvent(fut, FutureEvent.Pause)
|
||||
|
||||
# return here so that we don't remove the closure below
|
||||
return
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user