mirror of
https://github.com/status-im/nim-chronos.git
synced 2025-03-02 11:50:38 +00:00
Applies chronos conventions
This commit is contained in:
parent
e07f0dc049
commit
ac2fabedf7
@ -15,7 +15,7 @@ import std/[tables, strutils, heapqueue, deques]
|
|||||||
import stew/results
|
import stew/results
|
||||||
import "."/[config, futures, osdefs, oserrno, osutils, timer]
|
import "."/[config, futures, osdefs, oserrno, osutils, timer]
|
||||||
|
|
||||||
when defined(chronosEnableCallbackDurationMetric):
|
when chronosEnableCallbackDurationMetric:
|
||||||
import std/monotimes
|
import std/monotimes
|
||||||
import pkg/metrics
|
import pkg/metrics
|
||||||
|
|
||||||
@ -266,14 +266,14 @@ template processCallbacks(loop: untyped) =
|
|||||||
if isSentinel(callable):
|
if isSentinel(callable):
|
||||||
break
|
break
|
||||||
if not(isNil(callable.function)):
|
if not(isNil(callable.function)):
|
||||||
when defined(chronosEnableCallbackDurationMetric):
|
when chronosEnableCallbackDurationMetric:
|
||||||
let startTime = getMonoTime().ticks
|
let startTime = getMonoTime().ticks
|
||||||
|
|
||||||
callable.function(callable.udata)
|
callable.function(callable.udata)
|
||||||
|
|
||||||
when defined(chronosEnableCallbackDurationMetric):
|
when chronosEnableCallbackDurationMetric:
|
||||||
let durationUs = (getMonoTime().ticks - startTime) div 1000
|
let durationUs = (getMonoTime().ticks - startTime) div 1000
|
||||||
chronosCallbackDuration.set(durationNs)
|
chronosCallbackDuration.set(durationUs)
|
||||||
|
|
||||||
proc raiseAsDefect*(exc: ref Exception, msg: string) {.noreturn, noinline.} =
|
proc raiseAsDefect*(exc: ref Exception, msg: string) {.noreturn, noinline.} =
|
||||||
# Reraise an exception as a Defect, where it's unexpected and can't be handled
|
# Reraise an exception as a Defect, where it's unexpected and can't be handled
|
||||||
|
@ -70,7 +70,7 @@ when (NimMajor, NimMinor) >= (1, 4):
|
|||||||
""
|
""
|
||||||
## OS polling engine type which is going to be used by chronos.
|
## 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.
|
## At the cost of some performance, produce a 'chronosCallbackDuration' metric.
|
||||||
## Useful for detecting application stalling/blocking.
|
## Useful for detecting application stalling/blocking.
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user