From 48abae1fffea66a7878bd874144ff190e5a8a52a Mon Sep 17 00:00:00 2001 From: Jaremy Creechley Date: Tue, 28 Nov 2023 22:44:24 -0700 Subject: [PATCH] import tests --- chronos/futures.nim | 5 ++--- chronos/internal/asyncfutures.nim | 10 +++++----- 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/chronos/futures.nim b/chronos/futures.nim index 90f4fa5..01132ca 100644 --- a/chronos/futures.nim +++ b/chronos/futures.nim @@ -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, diff --git a/chronos/internal/asyncfutures.nim b/chronos/internal/asyncfutures.nim index ee58eb5..a81ec7d 100644 --- a/chronos/internal/asyncfutures.nim +++ b/chronos/internal/asyncfutures.nim @@ -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