Fix the build with -d:asyncBackend=none
This commit is contained in:
parent
02d120b7f6
commit
03975dadf6
1 changed files with 29 additions and 19 deletions
|
|
@ -259,32 +259,43 @@ proc writeFileSync(s: OutputStream, src: pointer, srcLen: Natural)
|
||||||
writeStartAddr, writeLen):
|
writeStartAddr, writeLen):
|
||||||
file.writeBuffer(writeStartAddr, writeLen)
|
file.writeBuffer(writeStartAddr, writeLen)
|
||||||
|
|
||||||
let fileOutputVTable = OutputStreamVTable(
|
proc flushFileSync(s: OutputStream)
|
||||||
writeSync: writeFileSync,
|
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
||||||
writeAsync: proc (s: OutputStream, src: pointer, srcLen: Natural): Future[void]
|
flushFile FileOutputStream(s).file
|
||||||
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
|
||||||
|
proc closeFileSync(s: OutputStream)
|
||||||
|
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
||||||
|
close FileOutputStream(s).file
|
||||||
|
|
||||||
|
when fsAsyncSupport:
|
||||||
|
proc writeFileAsync(s: OutputStream, src: pointer, srcLen: Natural): Future[void]
|
||||||
|
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
||||||
fsAssert FileOutputStream(s).allowAsyncOps
|
fsAssert FileOutputStream(s).allowAsyncOps
|
||||||
writeFileSync(s, src, srcLen)
|
writeFileSync(s, src, srcLen)
|
||||||
result = newFuture[void]()
|
result = newFuture[void]()
|
||||||
fsTranslateErrors "Unexpected exception from merely completing a future":
|
fsTranslateErrors "Unexpected exception from merely completing a future":
|
||||||
result.complete()
|
result.complete()
|
||||||
,
|
|
||||||
flushSync: proc (s: OutputStream)
|
proc flushFileAsync(s: OutputStream): Future[void]
|
||||||
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
||||||
flushFile FileOutputStream(s).file
|
|
||||||
,
|
|
||||||
flushAsync: proc (s: OutputStream): Future[void]
|
|
||||||
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
|
||||||
fsAssert FileOutputStream(s).allowAsyncOps
|
fsAssert FileOutputStream(s).allowAsyncOps
|
||||||
flushFile FileOutputStream(s).file
|
flushFile FileOutputStream(s).file
|
||||||
result = newFuture[void]()
|
result = newFuture[void]()
|
||||||
fsTranslateErrors "Unexpected exception from merely completing a future":
|
fsTranslateErrors "Unexpected exception from merely completing a future":
|
||||||
result.complete()
|
result.complete()
|
||||||
,
|
|
||||||
closeSync: proc (s: OutputStream)
|
let fileOutputVTable = when fsAsyncSupport:
|
||||||
{.nimcall, gcsafe, raises: [IOError, Defect].} =
|
OutputStreamVTable(
|
||||||
close FileOutputStream(s).file
|
writeSync: writeFileSync,
|
||||||
)
|
writeAsync: writeFileAsync,
|
||||||
|
flushSync: flushFileSync,
|
||||||
|
flushAsync: flushFileAsync,
|
||||||
|
closeSync: closeFileSync)
|
||||||
|
else:
|
||||||
|
OutputStreamVTable(
|
||||||
|
writeSync: writeFileSync,
|
||||||
|
flushSync: flushFileSync,
|
||||||
|
closeSync: closeFileSync)
|
||||||
|
|
||||||
template vtableAddr*(vtable: OutputStreamVTable): ptr OutputStreamVTable =
|
template vtableAddr*(vtable: OutputStreamVTable): ptr OutputStreamVTable =
|
||||||
## This is a simple work-around for the somewhat broken side
|
## This is a simple work-around for the somewhat broken side
|
||||||
|
|
@ -862,7 +873,7 @@ when fsAsyncSupport:
|
||||||
let s = OutputStream sp
|
let s = OutputStream sp
|
||||||
flushImpl(s, fsAwait, writeAsync, flushAsync)
|
flushImpl(s, fsAwait, writeAsync, flushAsync)
|
||||||
|
|
||||||
proc flushSync*(s: AsyncOutputStream) {.async.} =
|
proc flushAsync*(s: AsyncOutputStream) {.async.} =
|
||||||
flush s
|
flush s
|
||||||
|
|
||||||
template close*(sp: AsyncOutputStream) =
|
template close*(sp: AsyncOutputStream) =
|
||||||
|
|
@ -872,6 +883,5 @@ when fsAsyncSupport:
|
||||||
if s.closeFut != nil:
|
if s.closeFut != nil:
|
||||||
fsAwait s.closeFut
|
fsAwait s.closeFut
|
||||||
|
|
||||||
proc closeSync*(s: AsyncOutputStream) {.async.} =
|
proc closeAsync*(s: AsyncOutputStream) {.async.} =
|
||||||
close s
|
close s
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue