Add asynctools adapter

This commit is contained in:
Zahary Karadjov 2020-06-08 22:37:22 +03:00
commit 5df69fc696
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
7 changed files with 137 additions and 31 deletions

View file

@ -123,7 +123,7 @@ template close*(sp: AsyncOutputStream) =
flush(Async s)
disconnectOutputDevice(s)
if s.closeFut != nil:
await s.closeFut
fsAwait s.closeFut
proc closeAsync*(s: AsyncOutputStream) {.async.} =
close s
@ -311,7 +311,7 @@ proc drainAllBuffersSync(s: OutputStream, buf: pointer, bufSize: Natural) =
s.spanEndPos += s.span.len
proc drainAllBuffersAsync(s: OutputStream, buf: pointer, bufSize: Natural) {.async.} =
await s.vtable.writeAsync(s, buf, bufSize)
fsAwait s.vtable.writeAsync(s, buf, bufSize)
s.span = s.buffers.getWritableSpan()
s.spanEndPos += s.span.len