Better name and docs for the 'nonBlockingReads' facility
This commit is contained in:
parent
8b863f7798
commit
dd63bbfd1c
3 changed files with 18 additions and 18 deletions
|
|
@ -274,22 +274,20 @@ func getBestContiguousRunway(s: InputStream): Natural =
|
|||
flipPage s
|
||||
result = s.span.len
|
||||
|
||||
template nonBlockingReads*(sp: InputStream|AsyncInputStream, newName, blk: untyped) =
|
||||
template withReadableRange*(sp: InputStream|AsyncInputStream,
|
||||
rangeLen: Natural,
|
||||
rangeStreamVarName, blk: untyped) =
|
||||
let s = InputStream sp
|
||||
const sname = astToStr(sp)
|
||||
|
||||
let vtable = s.vtable
|
||||
s.vtable = nil
|
||||
|
||||
try:
|
||||
let `newName` {.inject.} = s
|
||||
let `rangeStreamVarName` {.inject.} = s
|
||||
blk
|
||||
finally:
|
||||
s.vtable = vtable
|
||||
|
||||
template nonBlockingReads*(sp: InputStream|AsyncInputStream, blk: untyped) =
|
||||
nonBlockingReads(sp, astToStr(sp), blk)
|
||||
|
||||
func totalUnconsumedBytes*(s: InputStream): Natural =
|
||||
## Returns the number of bytes that are currently sitting within the stream
|
||||
## buffers and that can be consumed with `read` or `advance`.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue