Skip to content

Commit

Permalink
Applies chronos conventions
Browse files Browse the repository at this point in the history
  • Loading branch information
benbierens committed Aug 8, 2023
1 parent e07f0dc commit ac2fabe
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
8 changes: 4 additions & 4 deletions chronos/asyncloop.nim
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import std/[tables, strutils, heapqueue, deques]
import stew/results
import "."/[config, futures, osdefs, oserrno, osutils, timer]

when defined(chronosEnableCallbackDurationMetric):
when chronosEnableCallbackDurationMetric:
import std/monotimes
import pkg/metrics

Expand Down Expand Up @@ -266,14 +266,14 @@ template processCallbacks(loop: untyped) =
if isSentinel(callable):
break
if not(isNil(callable.function)):
when defined(chronosEnableCallbackDurationMetric):
when chronosEnableCallbackDurationMetric:
let startTime = getMonoTime().ticks

callable.function(callable.udata)

when defined(chronosEnableCallbackDurationMetric):
when chronosEnableCallbackDurationMetric:
let durationUs = (getMonoTime().ticks - startTime) div 1000
chronosCallbackDuration.set(durationNs)
chronosCallbackDuration.set(durationUs)

proc raiseAsDefect*(exc: ref Exception, msg: string) {.noreturn, noinline.} =
# Reraise an exception as a Defect, where it's unexpected and can't be handled
Expand Down
2 changes: 1 addition & 1 deletion chronos/config.nim
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ when (NimMajor, NimMinor) >= (1, 4):
""
## OS polling engine type which is going to be used by chronos.

chronosEnableCallbackDurationMetric {.booldefine.} = false
chronosEnableCallbackDurationMetric* {.booldefine.} = defined(chronosEnableCallbackDurationMetric)
## At the cost of some performance, produce a 'chronosCallbackDuration' metric.
## Useful for detecting application stalling/blocking.

Expand Down

0 comments on commit ac2fabe

Please sign in to comment.