Various fixes to FutureStreams based on PR feedback.
This commit is contained in:
parent
912d95a6ea
commit
f9cce32097
7 changed files with 72 additions and 48 deletions
|
|
@ -9,7 +9,7 @@
|
|||
|
||||
include "system/inclrtl"
|
||||
|
||||
import os, oids, tables, strutils, times, heapqueue, queues
|
||||
import os, oids, tables, strutils, times, heapqueue
|
||||
|
||||
import nativesockets, net, deques
|
||||
|
||||
|
|
@ -1387,6 +1387,17 @@ proc send*(socket: AsyncFD, data: string,
|
|||
# -- Await Macro
|
||||
include asyncmacro
|
||||
|
||||
proc readAll*(future: FutureStream[string]): Future[string] {.async.} =
|
||||
## Returns a future that will complete when all the string data from the
|
||||
## specified future stream is retrieved.
|
||||
result = ""
|
||||
while true:
|
||||
let (hasValue, value) = await future.read()
|
||||
if hasValue:
|
||||
result.add(value)
|
||||
else:
|
||||
break
|
||||
|
||||
proc recvLine*(socket: AsyncFD): Future[string] {.async, deprecated.} =
|
||||
## Reads a line of data from ``socket``. Returned future will complete once
|
||||
## a full line is read or an error occurs.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue