Remove `sink` and `chronosMoveSink()` usage. (#524)
This commit is contained in:
parent
d4f1487b0c
commit
035288f3f0
|
@ -202,14 +202,14 @@ proc finish(fut: FutureBase, state: FutureState) =
|
||||||
when chronosFutureTracking:
|
when chronosFutureTracking:
|
||||||
scheduleDestructor(fut)
|
scheduleDestructor(fut)
|
||||||
|
|
||||||
proc complete[T](future: Future[T], val: sink T, loc: ptr SrcLoc) =
|
proc complete[T](future: Future[T], val: T, loc: ptr SrcLoc) =
|
||||||
if not(future.cancelled()):
|
if not(future.cancelled()):
|
||||||
checkFinished(future, loc)
|
checkFinished(future, loc)
|
||||||
doAssert(isNil(future.internalError))
|
doAssert(isNil(future.internalError))
|
||||||
future.internalValue = chronosMoveSink(val)
|
future.internalValue = val
|
||||||
future.finish(FutureState.Completed)
|
future.finish(FutureState.Completed)
|
||||||
|
|
||||||
template complete*[T](future: Future[T], val: sink T) =
|
template complete*[T](future: Future[T], val: T) =
|
||||||
## Completes ``future`` with value ``val``.
|
## Completes ``future`` with value ``val``.
|
||||||
complete(future, val, getSrcLocation())
|
complete(future, val, getSrcLocation())
|
||||||
|
|
||||||
|
|
|
@ -736,7 +736,7 @@ proc write*(wstream: AsyncStreamWriter, pbytes: pointer,
|
||||||
await item.future
|
await item.future
|
||||||
wstream.bytesCount = wstream.bytesCount + uint64(item.size)
|
wstream.bytesCount = wstream.bytesCount + uint64(item.size)
|
||||||
|
|
||||||
proc write*(wstream: AsyncStreamWriter, sbytes: sink seq[byte],
|
proc write*(wstream: AsyncStreamWriter, sbytes: seq[byte],
|
||||||
msglen = -1) {.
|
msglen = -1) {.
|
||||||
async: (raises: [CancelledError, AsyncStreamError]).} =
|
async: (raises: [CancelledError, AsyncStreamError]).} =
|
||||||
## Write sequence of bytes ``sbytes`` of length ``msglen`` to writer
|
## Write sequence of bytes ``sbytes`` of length ``msglen`` to writer
|
||||||
|
@ -771,14 +771,14 @@ proc write*(wstream: AsyncStreamWriter, sbytes: sink seq[byte],
|
||||||
wstream.bytesCount = wstream.bytesCount + uint64(length)
|
wstream.bytesCount = wstream.bytesCount + uint64(length)
|
||||||
else:
|
else:
|
||||||
let item = WriteItem(
|
let item = WriteItem(
|
||||||
kind: Sequence, dataSeq: move(sbytes), size: length,
|
kind: Sequence, dataSeq: sbytes, size: length,
|
||||||
future: Future[void].Raising([CancelledError, AsyncStreamError])
|
future: Future[void].Raising([CancelledError, AsyncStreamError])
|
||||||
.init("async.stream.write(seq)"))
|
.init("async.stream.write(seq)"))
|
||||||
await wstream.queue.put(item)
|
await wstream.queue.put(item)
|
||||||
await item.future
|
await item.future
|
||||||
wstream.bytesCount = wstream.bytesCount + uint64(item.size)
|
wstream.bytesCount = wstream.bytesCount + uint64(item.size)
|
||||||
|
|
||||||
proc write*(wstream: AsyncStreamWriter, sbytes: sink string,
|
proc write*(wstream: AsyncStreamWriter, sbytes: string,
|
||||||
msglen = -1) {.
|
msglen = -1) {.
|
||||||
async: (raises: [CancelledError, AsyncStreamError]).} =
|
async: (raises: [CancelledError, AsyncStreamError]).} =
|
||||||
## Write string ``sbytes`` of length ``msglen`` to writer stream ``wstream``.
|
## Write string ``sbytes`` of length ``msglen`` to writer stream ``wstream``.
|
||||||
|
@ -812,7 +812,7 @@ proc write*(wstream: AsyncStreamWriter, sbytes: sink string,
|
||||||
wstream.bytesCount = wstream.bytesCount + uint64(length)
|
wstream.bytesCount = wstream.bytesCount + uint64(length)
|
||||||
else:
|
else:
|
||||||
let item = WriteItem(
|
let item = WriteItem(
|
||||||
kind: String, dataStr: move(sbytes), size: length,
|
kind: String, dataStr: sbytes, size: length,
|
||||||
future: Future[void].Raising([CancelledError, AsyncStreamError])
|
future: Future[void].Raising([CancelledError, AsyncStreamError])
|
||||||
.init("async.stream.write(string)"))
|
.init("async.stream.write(string)"))
|
||||||
await wstream.queue.put(item)
|
await wstream.queue.put(item)
|
||||||
|
|
|
@ -161,7 +161,7 @@ proc tlsWriteRec(engine: ptr SslEngineContext,
|
||||||
var length = 0'u
|
var length = 0'u
|
||||||
var buf = sslEngineSendrecBuf(engine[], length)
|
var buf = sslEngineSendrecBuf(engine[], length)
|
||||||
doAssert(length != 0 and not isNil(buf))
|
doAssert(length != 0 and not isNil(buf))
|
||||||
await writer.wsource.write(chronosMoveSink(buf), int(length))
|
await writer.wsource.write(buf, int(length))
|
||||||
sslEngineSendrecAck(engine[], length)
|
sslEngineSendrecAck(engine[], length)
|
||||||
TLSResult.Success
|
TLSResult.Success
|
||||||
except AsyncStreamError as exc:
|
except AsyncStreamError as exc:
|
||||||
|
|
|
@ -873,7 +873,7 @@ proc send*(transp: DatagramTransport, pbytes: pointer,
|
||||||
retFuture.fail(getTransportOsError(wres.error()))
|
retFuture.fail(getTransportOsError(wres.error()))
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc send*(transp: DatagramTransport, msg: sink string,
|
proc send*(transp: DatagramTransport, msg: string,
|
||||||
msglen = -1): Future[void] {.
|
msglen = -1): Future[void] {.
|
||||||
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
||||||
## Send string ``msg`` using transport ``transp`` to remote destination
|
## Send string ``msg`` using transport ``transp`` to remote destination
|
||||||
|
@ -882,7 +882,7 @@ proc send*(transp: DatagramTransport, msg: sink string,
|
||||||
transp.checkClosed(retFuture)
|
transp.checkClosed(retFuture)
|
||||||
|
|
||||||
let length = if msglen <= 0: len(msg) else: msglen
|
let length = if msglen <= 0: len(msg) else: msglen
|
||||||
var localCopy = chronosMoveSink(msg)
|
var localCopy = msg
|
||||||
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
||||||
|
|
||||||
let vector = GramVector(kind: WithoutAddress, buf: baseAddr localCopy,
|
let vector = GramVector(kind: WithoutAddress, buf: baseAddr localCopy,
|
||||||
|
@ -896,16 +896,16 @@ proc send*(transp: DatagramTransport, msg: sink string,
|
||||||
retFuture.fail(getTransportOsError(wres.error()))
|
retFuture.fail(getTransportOsError(wres.error()))
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc send*[T](transp: DatagramTransport, msg: sink seq[T],
|
proc send*[T](transp: DatagramTransport, msg: seq[T],
|
||||||
msglen = -1): Future[void] {.
|
msglen = -1): Future[void] {.
|
||||||
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
||||||
## Send string ``msg`` using transport ``transp`` to remote destination
|
## Send string ``msg`` using transport ``transp`` to remote destination
|
||||||
## address which was bounded on transport.
|
## address which was bounded on transport.
|
||||||
let retFuture = newFuture[void]("datagram.transport.send(seq)")
|
let retFuture = newFuture[void]("datagram.transport.send(seq)")
|
||||||
transp.checkClosed(retFuture)
|
transp.checkClosed(retFuture)
|
||||||
|
|
||||||
let length = if msglen <= 0: (len(msg) * sizeof(T)) else: (msglen * sizeof(T))
|
let length = if msglen <= 0: (len(msg) * sizeof(T)) else: (msglen * sizeof(T))
|
||||||
var localCopy = chronosMoveSink(msg)
|
var localCopy = msg
|
||||||
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
||||||
|
|
||||||
let vector = GramVector(kind: WithoutAddress, buf: baseAddr localCopy,
|
let vector = GramVector(kind: WithoutAddress, buf: baseAddr localCopy,
|
||||||
|
@ -935,7 +935,7 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
||||||
msg: sink string, msglen = -1): Future[void] {.
|
msg: string, msglen = -1): Future[void] {.
|
||||||
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
||||||
## Send string ``msg`` using transport ``transp`` to remote destination
|
## Send string ``msg`` using transport ``transp`` to remote destination
|
||||||
## address ``remote``.
|
## address ``remote``.
|
||||||
|
@ -943,7 +943,7 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
||||||
transp.checkClosed(retFuture)
|
transp.checkClosed(retFuture)
|
||||||
|
|
||||||
let length = if msglen <= 0: len(msg) else: msglen
|
let length = if msglen <= 0: len(msg) else: msglen
|
||||||
var localCopy = chronosMoveSink(msg)
|
var localCopy = msg
|
||||||
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
||||||
|
|
||||||
let vector = GramVector(kind: WithAddress, buf: baseAddr localCopy,
|
let vector = GramVector(kind: WithAddress, buf: baseAddr localCopy,
|
||||||
|
@ -958,14 +958,14 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc sendTo*[T](transp: DatagramTransport, remote: TransportAddress,
|
proc sendTo*[T](transp: DatagramTransport, remote: TransportAddress,
|
||||||
msg: sink seq[T], msglen = -1): Future[void] {.
|
msg: seq[T], msglen = -1): Future[void] {.
|
||||||
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
||||||
## Send sequence ``msg`` using transport ``transp`` to remote destination
|
## Send sequence ``msg`` using transport ``transp`` to remote destination
|
||||||
## address ``remote``.
|
## address ``remote``.
|
||||||
let retFuture = newFuture[void]("datagram.transport.sendTo(seq)")
|
let retFuture = newFuture[void]("datagram.transport.sendTo(seq)")
|
||||||
transp.checkClosed(retFuture)
|
transp.checkClosed(retFuture)
|
||||||
let length = if msglen <= 0: (len(msg) * sizeof(T)) else: (msglen * sizeof(T))
|
let length = if msglen <= 0: (len(msg) * sizeof(T)) else: (msglen * sizeof(T))
|
||||||
var localCopy = chronosMoveSink(msg)
|
var localCopy = msg
|
||||||
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
||||||
|
|
||||||
let vector = GramVector(kind: WithAddress, buf: baseAddr localCopy,
|
let vector = GramVector(kind: WithAddress, buf: baseAddr localCopy,
|
||||||
|
|
|
@ -2248,7 +2248,7 @@ proc write*(transp: StreamTransport, pbytes: pointer,
|
||||||
retFuture.fail(getTransportOsError(wres.error()))
|
retFuture.fail(getTransportOsError(wres.error()))
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc write*(transp: StreamTransport, msg: sink string,
|
proc write*(transp: StreamTransport, msg: string,
|
||||||
msglen = -1): Future[int] {.
|
msglen = -1): Future[int] {.
|
||||||
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
||||||
## Write data from string ``msg`` using transport ``transp``.
|
## Write data from string ``msg`` using transport ``transp``.
|
||||||
|
@ -2267,7 +2267,7 @@ proc write*(transp: StreamTransport, msg: sink string,
|
||||||
let
|
let
|
||||||
written = nbytes - rbytes # In case fastWrite wrote some
|
written = nbytes - rbytes # In case fastWrite wrote some
|
||||||
|
|
||||||
var localCopy = chronosMoveSink(msg)
|
var localCopy = msg
|
||||||
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
||||||
|
|
||||||
pbytes = cast[ptr byte](addr localCopy[written])
|
pbytes = cast[ptr byte](addr localCopy[written])
|
||||||
|
@ -2280,7 +2280,7 @@ proc write*(transp: StreamTransport, msg: sink string,
|
||||||
retFuture.fail(getTransportOsError(wres.error()))
|
retFuture.fail(getTransportOsError(wres.error()))
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc write*[T](transp: StreamTransport, msg: sink seq[T],
|
proc write*[T](transp: StreamTransport, msg: seq[T],
|
||||||
msglen = -1): Future[int] {.
|
msglen = -1): Future[int] {.
|
||||||
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
async: (raw: true, raises: [TransportError, CancelledError]).} =
|
||||||
## Write sequence ``msg`` using transport ``transp``.
|
## Write sequence ``msg`` using transport ``transp``.
|
||||||
|
@ -2300,7 +2300,7 @@ proc write*[T](transp: StreamTransport, msg: sink seq[T],
|
||||||
let
|
let
|
||||||
written = nbytes - rbytes # In case fastWrite wrote some
|
written = nbytes - rbytes # In case fastWrite wrote some
|
||||||
|
|
||||||
var localCopy = chronosMoveSink(msg)
|
var localCopy = msg
|
||||||
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
|
||||||
|
|
||||||
pbytes = cast[ptr byte](addr localCopy[written])
|
pbytes = cast[ptr byte](addr localCopy[written])
|
||||||
|
|
Loading…
Reference in New Issue