allowAsyncOps applies to async file flushing as well

This commit is contained in:
Zahary Karadjov 2022-01-20 18:39:31 +02:00
commit 02d120b7f6
2 changed files with 9 additions and 1 deletions

View file

@ -273,6 +273,14 @@ let fileOutputVTable = OutputStreamVTable(
{.nimcall, gcsafe, raises: [IOError, Defect].} =
flushFile FileOutputStream(s).file
,
flushAsync: proc (s: OutputStream): Future[void]
{.nimcall, gcsafe, raises: [IOError, Defect].} =
fsAssert FileOutputStream(s).allowAsyncOps
flushFile FileOutputStream(s).file
result = newFuture[void]()
fsTranslateErrors "Unexpected exception from merely completing a future":
result.complete()
,
closeSync: proc (s: OutputStream)
{.nimcall, gcsafe, raises: [IOError, Defect].} =
close FileOutputStream(s).file

View file

@ -127,7 +127,7 @@ when fsAsyncSupport:
flush destination
,
flushAsync: proc (s: OutputStream): Future[void]
{.nimcall, gcsafe, raises: [IOError, Defect].} =
{.nimcall, gcsafe, raises: [IOError, Defect].} =
fsTranslateErrors "Unexpected error from the async macro":
let destination = LayeredOutputStream(s).destination
if destination != nil: