From 02d120b7f64067123d5f318ac22ae36fae49d7b1 Mon Sep 17 00:00:00 2001 From: Zahary Karadjov Date: Thu, 20 Jan 2022 18:39:31 +0200 Subject: [PATCH] allowAsyncOps applies to async file flushing as well --- faststreams/outputs.nim | 8 ++++++++ faststreams/pipelines.nim | 2 +- 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/faststreams/outputs.nim b/faststreams/outputs.nim index 47bd990..efa508e 100644 --- a/faststreams/outputs.nim +++ b/faststreams/outputs.nim @@ -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 diff --git a/faststreams/pipelines.nim b/faststreams/pipelines.nim index 82b3bd5..aa72f6e 100644 --- a/faststreams/pipelines.nim +++ b/faststreams/pipelines.nim @@ -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: