asyncraises for threadsync (#495)
* asyncraises for threadsync * missing bracket * missing exception
This commit is contained in:
parent
3ca2c5e6b5
commit
e296ae30c8
|
@ -1553,7 +1553,7 @@ when defined(windows):
|
||||||
|
|
||||||
proc waitForSingleObject*(handle: HANDLE,
|
proc waitForSingleObject*(handle: HANDLE,
|
||||||
timeout: Duration): Future[WaitableResult] {.
|
timeout: Duration): Future[WaitableResult] {.
|
||||||
raises: [].} =
|
async: (raises: [AsyncError, CancelledError], raw: true).} =
|
||||||
## Waits until the specified object is in the signaled state or the
|
## Waits until the specified object is in the signaled state or the
|
||||||
## time-out interval elapses. WaitForSingleObject() for asynchronous world.
|
## time-out interval elapses. WaitForSingleObject() for asynchronous world.
|
||||||
let flags = WT_EXECUTEONLYONCE
|
let flags = WT_EXECUTEONLYONCE
|
||||||
|
|
|
@ -272,7 +272,8 @@ proc waitSync*(signal: ThreadSignalPtr,
|
||||||
else:
|
else:
|
||||||
return ok(true)
|
return ok(true)
|
||||||
|
|
||||||
proc fire*(signal: ThreadSignalPtr): Future[void] =
|
proc fire*(signal: ThreadSignalPtr): Future[void] {.
|
||||||
|
async: (raises: [AsyncError, CancelledError], raw: true).} =
|
||||||
## Set state of ``signal`` to signaled in asynchronous way.
|
## Set state of ``signal`` to signaled in asynchronous way.
|
||||||
var retFuture = newFuture[void]("asyncthreadsignal.fire")
|
var retFuture = newFuture[void]("asyncthreadsignal.fire")
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
|
@ -356,14 +357,17 @@ proc fire*(signal: ThreadSignalPtr): Future[void] =
|
||||||
retFuture
|
retFuture
|
||||||
|
|
||||||
when defined(windows):
|
when defined(windows):
|
||||||
proc wait*(signal: ThreadSignalPtr) {.async.} =
|
proc wait*(signal: ThreadSignalPtr) {.
|
||||||
|
async: (raises: [AsyncError, CancelledError]).} =
|
||||||
let handle = signal[].event
|
let handle = signal[].event
|
||||||
let res = await waitForSingleObject(handle, InfiniteDuration)
|
let res = await waitForSingleObject(handle, InfiniteDuration)
|
||||||
# There should be no other response, because we use `InfiniteDuration`.
|
# There should be no other response, because we use `InfiniteDuration`.
|
||||||
doAssert(res == WaitableResult.Ok)
|
doAssert(res == WaitableResult.Ok)
|
||||||
else:
|
else:
|
||||||
proc wait*(signal: ThreadSignalPtr): Future[void] =
|
proc wait*(signal: ThreadSignalPtr): Future[void] {.
|
||||||
var retFuture = newFuture[void]("asyncthreadsignal.wait")
|
async: (raises: [AsyncError, CancelledError], raw: true).} =
|
||||||
|
let retFuture = Future[void].Raising([AsyncError, CancelledError]).init(
|
||||||
|
"asyncthreadsignal.wait")
|
||||||
var data = 1'u64
|
var data = 1'u64
|
||||||
let eventFd =
|
let eventFd =
|
||||||
when defined(linux):
|
when defined(linux):
|
||||||
|
|
Loading…
Reference in New Issue