build: bump vendor/nim-chronos
Also make necessary adjustments to `task_runner/[asyncloop, asyncsync]`
This commit is contained in:
parent
a87f3f85be
commit
f9220a996a
|
@ -9,9 +9,9 @@
|
|||
# Licensed under either of
|
||||
# Apache License, version 2.0, (LICENSE-APACHEv2)
|
||||
# MIT license (LICENSE-MIT)
|
||||
import os, selectors
|
||||
import os
|
||||
|
||||
import chronos/asyncloop
|
||||
import chronos/[asyncloop, selectors2]
|
||||
export asyncloop
|
||||
|
||||
when defined(windows):
|
||||
|
@ -141,22 +141,28 @@ else:
|
|||
var moment: Moment
|
||||
|
||||
proc handleContinuation(udata: pointer) {.gcsafe.} =
|
||||
try:
|
||||
if not(retFuture.finished()):
|
||||
loop.selector.unregister(event)
|
||||
if isNil(udata):
|
||||
retFuture.complete(false)
|
||||
else:
|
||||
retFuture.complete(true)
|
||||
except IOSelectorsException as e:
|
||||
raise newException(Defect, e.msg)
|
||||
|
||||
proc cancel(udata: pointer) {.gcsafe.} =
|
||||
proc cancellation(udata: pointer) {.gcsafe.} =
|
||||
try:
|
||||
if not(retFuture.finished()):
|
||||
loop.selector.unregister(event)
|
||||
if timeout != InfiniteDuration:
|
||||
removeTimer(moment, handleContinuation, nil)
|
||||
except IOSelectorsException as e:
|
||||
raise newException(Defect, e.msg)
|
||||
|
||||
if timeout != InfiniteDuration:
|
||||
moment = Moment.fromNow(timeout)
|
||||
addTimer(moment, handleContinuation, nil)
|
||||
discard setTimer(moment, handleContinuation, nil)
|
||||
|
||||
let fd = event.getFd()
|
||||
loop.selector.registerEvent(event, data)
|
||||
|
@ -170,5 +176,5 @@ else:
|
|||
retFuture.fail(newException(ValueError,
|
||||
"Event descriptor not registered."))
|
||||
|
||||
retFuture.cancelCallback = cancel
|
||||
retFuture.cancelCallback = cancellation
|
||||
return retFuture
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
# MIT license (LICENSE-MIT)
|
||||
import os
|
||||
|
||||
import chronos/[asyncloop, asyncsync, handles, timer]
|
||||
import chronos/[asyncloop, asyncsync, handles, selectors2, timer]
|
||||
export asyncsync
|
||||
|
||||
import ./osapi
|
||||
|
@ -216,7 +216,8 @@ else:
|
|||
else:
|
||||
let fd = AsyncFD(event.rfd)
|
||||
|
||||
proc contiunuation(udata: pointer) {.gcsafe.} =
|
||||
proc contiunuation(udata: pointer) {.gcsafe, raises: [Defect].} =
|
||||
try:
|
||||
if not(retFuture.finished()):
|
||||
var data: uint64 = 0
|
||||
if isNil(udata):
|
||||
|
@ -252,11 +253,16 @@ else:
|
|||
release(event.lock)
|
||||
retFuture.complete(WaitSuccess)
|
||||
break
|
||||
except IOSelectorsException, ValueError:
|
||||
raise newException(Defect, getCurrentExceptionMsg())
|
||||
|
||||
proc cancel(udata: pointer) {.gcsafe.} =
|
||||
proc cancellation(udata: pointer) {.gcsafe, raises: [Defect].} =
|
||||
try:
|
||||
if not(retFuture.finished()):
|
||||
removeTimer(moment, contiunuation, nil)
|
||||
removeReader(fd)
|
||||
except IOSelectorsException, ValueError:
|
||||
raise newException(Defect, getCurrentExceptionMsg())
|
||||
|
||||
if fd notin loop:
|
||||
register(fd)
|
||||
|
@ -265,7 +271,7 @@ else:
|
|||
moment = Moment.fromNow(timeout)
|
||||
addTimer(moment, contiunuation, nil)
|
||||
|
||||
retFuture.cancelCallback = cancel
|
||||
retFuture.cancelCallback = cancellation
|
||||
return retFuture
|
||||
|
||||
proc waitReady(fd: int, timeout: var Duration): WaitResult {.inline.} =
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit c066bfcb16482d82ef5b6fdbac85ec8f7565d56c
|
||||
Subproject commit aa36b645182fe2e25d442bb5e93b0b06cff897bc
|
Loading…
Reference in New Issue