mirror of
https://github.com/codex-storage/nim-codex.git
synced 2025-02-04 00:54:32 +00:00
e5df8c50d3
* style: nph setup * chore: formates codex/ and tests/ folder with nph 0.6.1
15 lines
342 B
Nim
15 lines
342 B
Nim
import pkg/chronos
|
|
|
|
template always*(condition: untyped, timeout = 50.millis): bool =
|
|
proc loop(): Future[bool] {.async.} =
|
|
let start = Moment.now()
|
|
while true:
|
|
if not condition:
|
|
return false
|
|
if Moment.now() > (start + timeout):
|
|
return true
|
|
else:
|
|
await sleepAsync(1.millis)
|
|
|
|
await loop()
|