diff options
author | bptato <nincsnevem662@gmail.com> | 2023-02-09 13:22:47 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-02-09 13:22:47 +0100 |
commit | 81290d7e577701f37a1c4559f0a7777b904e7ed7 (patch) | |
tree | ff3e16de6dfeafa1d3f5f6657484364bc9e87cd1 /src/display | |
parent | 9742a2b41d374b4eaea44c1c2d715bf704d752af (diff) | |
download | chawan-81290d7e577701f37a1c4559f0a7777b904e7ed7.tar.gz |
setTimeout, setInterval: hack to fix 0 timeout
Timers with a timeout < 1 seem to block indefinitely. No clue why.
Diffstat (limited to 'src/display')
-rw-r--r-- | src/display/client.nim | 4 |
1 files changed, 2 insertions, 2 deletions
diff --git a/src/display/client.nim b/src/display/client.nim index 1902e122..38a868dc 100644 --- a/src/display/client.nim +++ b/src/display/client.nim @@ -201,7 +201,7 @@ proc input(client: Client) = proc setTimeout[T: JSValue|string](client: Client, handler: T, timeout = 0): int {.jsfunc.} = let id = client.timeoutid inc client.timeoutid - let fdi = client.selector.registerTimer(timeout, true, nil) + let fdi = client.selector.registerTimer(max(timeout, 1), true, nil) client.timeout_fdis[fdi] = id when T is string: client.timeouts[id] = ((proc() = @@ -221,7 +221,7 @@ proc setTimeout[T: JSValue|string](client: Client, handler: T, timeout = 0): int proc setInterval[T: JSValue|string](client: Client, handler: T, interval = 0): int {.jsfunc.} = let id = client.timeoutid inc client.timeoutid - let fdi = client.selector.registerTimer(interval, false, nil) + let fdi = client.selector.registerTimer(max(interval, 1), false, nil) client.interval_fdis[fdi] = id when T is string: client.intervals[id] = ((proc() = |