diff options
author | Dmitriy Fomichev <xomachiner@gmail.com> | 2017-01-11 13:01:03 +0400 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-01-11 10:01:03 +0100 |
commit | d356c37185acdb7dec1feff5454209612e9ea9ad (patch) | |
tree | e3c72f7bdafebea74625c3b352bc6c87c62ac12a /lib | |
parent | d04ca6ef23409d95c4a8a76befdfb792e8514bf8 (diff) | |
download | Nim-d356c37185acdb7dec1feff5454209612e9ea9ad.tar.gz |
Workaround for the high cpu usage issue in coroutines on linux (#5186)
Fixes high cpu usage when all coroutines are asleep
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pure/coro.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/lib/pure/coro.nim b/lib/pure/coro.nim index 2a81b7317..0373708d0 100644 --- a/lib/pure/coro.nim +++ b/lib/pure/coro.nim @@ -66,14 +66,14 @@ proc run*() = ## Starts main event loop which exits when all coroutines exit. Calling this proc ## starts execution of first coroutine. var node = coroutines.head - var minDelay: float = 0 + var minDelay: int = 0 # in milliseconds var frame: PFrame while node != nil: var coro = node.value current = coro - os.sleep(int(minDelay * 1000)) + os.sleep(minDelay) - var remaining = coro.sleepTime - (epochTime() - coro.lastRun); + var remaining = int((coro.sleepTime - (epochTime() - coro.lastRun)) * 1000) if remaining <= 0: remaining = 0 let res = setjmp(mainCtx) |