Implement timeoutToNextByte

This commit is contained in:
Zahary Karadjov 2020-05-06 23:12:12 +03:00
commit fc76250d02
No known key found for this signature in database
GPG key ID: C8936F8A3073D609
2 changed files with 54 additions and 14 deletions

View file

@ -6,7 +6,7 @@ export
inputs, outputs, async_backend
type
FsAsyncPipe* = ref object
Pipe* = ref object
# TODO: Make these stream handles
input*: AsyncInputStream
output*: AsyncOutputStream
@ -218,16 +218,15 @@ proc pipeOutput*(buffers: PageBuffers,
destination: destination)
func asyncPipe*(pageSize = defaultPageSize,
maxBufferedBytes = defaultPageSize * 4): FsAsyncPipe =
maxBufferedBytes = defaultPageSize * 4): Pipe =
fsAssert pageSize > 0
FsAsyncPipe(buffers: initPageBuffers(pageSize, maxBufferedBytes))
Pipe(buffers: initPageBuffers(pageSize, maxBufferedBytes))
func initReader*(pipe: FsAsyncPipe): AsyncInputStream =
func initReader*(pipe: Pipe): AsyncInputStream =
result = pipeInput(pipe.buffers)
pipe.input = result
func initWriter*(pipe: FsAsyncPipe): AsyncOutputStream =
func initWriter*(pipe: Pipe): AsyncOutputStream =
result = pipeOutput(pipe.buffers)
pipe.output = result