don't await twise
This commit is contained in:
parent
e2b04fc30d
commit
1cef1b803b
|
@ -22,38 +22,38 @@ proc newConnection*(stream: LPStream): Connection =
|
||||||
new result
|
new result
|
||||||
result.stream = stream
|
result.stream = stream
|
||||||
|
|
||||||
method read*(s: Connection, n = -1): Future[seq[byte]] {.async, gcsafe.} =
|
method read*(s: Connection, n = -1): Future[seq[byte]] {.gcsafe.} =
|
||||||
result = await s.stream.read(n)
|
result = s.stream.read(n)
|
||||||
|
|
||||||
method readExactly*(s: Connection,
|
method readExactly*(s: Connection,
|
||||||
pbytes: pointer,
|
pbytes: pointer,
|
||||||
nbytes: int): Future[void] {.async, gcsafe.} =
|
nbytes: int): Future[void] {.gcsafe.} =
|
||||||
await s.stream.readExactly(pbytes, nbytes)
|
result = s.stream.readExactly(pbytes, nbytes)
|
||||||
|
|
||||||
method readLine*(s: Connection,
|
method readLine*(s: Connection,
|
||||||
limit = 0,
|
limit = 0,
|
||||||
sep = "\r\n"): Future[string] {.async, gcsafe.} =
|
sep = "\r\n"): Future[string] {.gcsafe.} =
|
||||||
result = await s.stream.readLine(limit, sep)
|
result = s.stream.readLine(limit, sep)
|
||||||
|
|
||||||
method readOnce*(s: Connection,
|
method readOnce*(s: Connection,
|
||||||
pbytes: pointer,
|
pbytes: pointer,
|
||||||
nbytes: int): Future[int] {.async, gcsafe.} =
|
nbytes: int): Future[int] {.gcsafe.} =
|
||||||
result = await s.stream.readOnce(pbytes, nbytes)
|
result = s.stream.readOnce(pbytes, nbytes)
|
||||||
|
|
||||||
method readUntil*(s: Connection,
|
method readUntil*(s: Connection,
|
||||||
pbytes: pointer,
|
pbytes: pointer,
|
||||||
nbytes: int,
|
nbytes: int,
|
||||||
sep: seq[byte]): Future[int] {.async, gcsafe.} =
|
sep: seq[byte]): Future[int] {.gcsafe.} =
|
||||||
result = await s.stream.readUntil(pbytes, nbytes, sep)
|
result = s.stream.readUntil(pbytes, nbytes, sep)
|
||||||
|
|
||||||
method write*(s: Connection, pbytes: pointer, nbytes: int) {.async, gcsafe.} =
|
method write*(s: Connection, pbytes: pointer, nbytes: int): Future[void] {.gcsafe.} =
|
||||||
await s.stream.write(pbytes, nbytes)
|
result = s.stream.write(pbytes, nbytes)
|
||||||
|
|
||||||
method write*(s: Connection, msg: string, msglen = -1) {.async, gcsafe.} =
|
method write*(s: Connection, msg: string, msglen = -1): Future[void] {.gcsafe.} =
|
||||||
await s.stream.write(msg, msglen)
|
result = s.stream.write(msg, msglen)
|
||||||
|
|
||||||
method write*(s: Connection, msg: seq[byte], msglen = -1) {.async, gcsafe.} =
|
method write*(s: Connection, msg: seq[byte], msglen = -1): Future[void] {.gcsafe.} =
|
||||||
await s.stream.write(msg, msglen)
|
result = s.stream.write(msg, msglen)
|
||||||
|
|
||||||
method close*(s: Connection) {.async, gcsafe.} =
|
method close*(s: Connection) {.async, gcsafe.} =
|
||||||
await s.stream.close()
|
await s.stream.close()
|
||||||
|
|
Loading…
Reference in New Issue