import tests

This commit is contained in:
Jaremy Creechley 2023-11-28 22:44:24 -07:00
parent 77dfb0d576
commit 48abae1fff
No known key found for this signature in database
GPG Key ID: 4E66FB67B21D3300
2 changed files with 7 additions and 8 deletions

View File

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

View File

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