asyncraises for threadsync (#495)

* asyncraises for threadsync

* missing bracket

* missing exception
This commit is contained in:
Jacek Sieka 2024-01-20 16:56:57 +01:00 committed by GitHub
parent 3ca2c5e6b5
commit e296ae30c8
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 9 additions and 5 deletions

View File

@ -1553,7 +1553,7 @@ when defined(windows):
proc waitForSingleObject*(handle: HANDLE,
timeout: Duration): Future[WaitableResult] {.
raises: [].} =
async: (raises: [AsyncError, CancelledError], raw: true).} =
## Waits until the specified object is in the signaled state or the
## time-out interval elapses. WaitForSingleObject() for asynchronous world.
let flags = WT_EXECUTEONLYONCE

View File

@ -272,7 +272,8 @@ proc waitSync*(signal: ThreadSignalPtr,
else:
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.
var retFuture = newFuture[void]("asyncthreadsignal.fire")
when defined(windows):
@ -356,14 +357,17 @@ proc fire*(signal: ThreadSignalPtr): Future[void] =
retFuture
when defined(windows):
proc wait*(signal: ThreadSignalPtr) {.async.} =
proc wait*(signal: ThreadSignalPtr) {.
async: (raises: [AsyncError, CancelledError]).} =
let handle = signal[].event
let res = await waitForSingleObject(handle, InfiniteDuration)
# There should be no other response, because we use `InfiniteDuration`.
doAssert(res == WaitableResult.Ok)
else:
proc wait*(signal: ThreadSignalPtr): Future[void] =
var retFuture = newFuture[void]("asyncthreadsignal.wait")
proc wait*(signal: ThreadSignalPtr): Future[void] {.
async: (raises: [AsyncError, CancelledError], raw: true).} =
let retFuture = Future[void].Raising([AsyncError, CancelledError]).init(
"asyncthreadsignal.wait")
var data = 1'u64
let eventFd =
when defined(linux):