Remove `sink` and `chronosMoveSink()` usage. (#524)

This commit is contained in:
Eugene Kabanov 2024-03-20 08:47:59 +02:00 committed by GitHub
parent d4f1487b0c
commit 035288f3f0
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
5 changed files with 21 additions and 21 deletions

View File

@ -202,14 +202,14 @@ proc finish(fut: FutureBase, state: FutureState) =
when chronosFutureTracking:
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()):
checkFinished(future, loc)
doAssert(isNil(future.internalError))
future.internalValue = chronosMoveSink(val)
future.internalValue = val
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``.
complete(future, val, getSrcLocation())

View File

@ -736,7 +736,7 @@ proc write*(wstream: AsyncStreamWriter, pbytes: pointer,
await item.future
wstream.bytesCount = wstream.bytesCount + uint64(item.size)
proc write*(wstream: AsyncStreamWriter, sbytes: sink seq[byte],
proc write*(wstream: AsyncStreamWriter, sbytes: seq[byte],
msglen = -1) {.
async: (raises: [CancelledError, AsyncStreamError]).} =
## 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)
else:
let item = WriteItem(
kind: Sequence, dataSeq: move(sbytes), size: length,
kind: Sequence, dataSeq: sbytes, size: length,
future: Future[void].Raising([CancelledError, AsyncStreamError])
.init("async.stream.write(seq)"))
await wstream.queue.put(item)
await item.future
wstream.bytesCount = wstream.bytesCount + uint64(item.size)
proc write*(wstream: AsyncStreamWriter, sbytes: sink string,
proc write*(wstream: AsyncStreamWriter, sbytes: string,
msglen = -1) {.
async: (raises: [CancelledError, AsyncStreamError]).} =
## 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)
else:
let item = WriteItem(
kind: String, dataStr: move(sbytes), size: length,
kind: String, dataStr: sbytes, size: length,
future: Future[void].Raising([CancelledError, AsyncStreamError])
.init("async.stream.write(string)"))
await wstream.queue.put(item)

View File

@ -161,7 +161,7 @@ proc tlsWriteRec(engine: ptr SslEngineContext,
var length = 0'u
var buf = sslEngineSendrecBuf(engine[], length)
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)
TLSResult.Success
except AsyncStreamError as exc:

View File

@ -873,7 +873,7 @@ proc send*(transp: DatagramTransport, pbytes: pointer,
retFuture.fail(getTransportOsError(wres.error()))
return retFuture
proc send*(transp: DatagramTransport, msg: sink string,
proc send*(transp: DatagramTransport, msg: string,
msglen = -1): Future[void] {.
async: (raw: true, raises: [TransportError, CancelledError]).} =
## Send string ``msg`` using transport ``transp`` to remote destination
@ -882,7 +882,7 @@ proc send*(transp: DatagramTransport, msg: sink string,
transp.checkClosed(retFuture)
let length = if msglen <= 0: len(msg) else: msglen
var localCopy = chronosMoveSink(msg)
var localCopy = msg
retFuture.addCallback(proc(_: pointer) = reset(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()))
return retFuture
proc send*[T](transp: DatagramTransport, msg: sink seq[T],
proc send*[T](transp: DatagramTransport, msg: seq[T],
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
## address which was bounded on transport.
let retFuture = newFuture[void]("datagram.transport.send(seq)")
transp.checkClosed(retFuture)
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))
let vector = GramVector(kind: WithoutAddress, buf: baseAddr localCopy,
@ -935,7 +935,7 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
return retFuture
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]).} =
## Send string ``msg`` using transport ``transp`` to remote destination
## address ``remote``.
@ -943,7 +943,7 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
transp.checkClosed(retFuture)
let length = if msglen <= 0: len(msg) else: msglen
var localCopy = chronosMoveSink(msg)
var localCopy = msg
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
let vector = GramVector(kind: WithAddress, buf: baseAddr localCopy,
@ -958,14 +958,14 @@ proc sendTo*(transp: DatagramTransport, remote: TransportAddress,
return retFuture
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]).} =
## Send sequence ``msg`` using transport ``transp`` to remote destination
## address ``remote``.
let retFuture = newFuture[void]("datagram.transport.sendTo(seq)")
transp.checkClosed(retFuture)
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))
let vector = GramVector(kind: WithAddress, buf: baseAddr localCopy,

View File

@ -2248,7 +2248,7 @@ proc write*(transp: StreamTransport, pbytes: pointer,
retFuture.fail(getTransportOsError(wres.error()))
return retFuture
proc write*(transp: StreamTransport, msg: sink string,
proc write*(transp: StreamTransport, msg: string,
msglen = -1): Future[int] {.
async: (raw: true, raises: [TransportError, CancelledError]).} =
## Write data from string ``msg`` using transport ``transp``.
@ -2267,7 +2267,7 @@ proc write*(transp: StreamTransport, msg: sink string,
let
written = nbytes - rbytes # In case fastWrite wrote some
var localCopy = chronosMoveSink(msg)
var localCopy = msg
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
pbytes = cast[ptr byte](addr localCopy[written])
@ -2280,7 +2280,7 @@ proc write*(transp: StreamTransport, msg: sink string,
retFuture.fail(getTransportOsError(wres.error()))
return retFuture
proc write*[T](transp: StreamTransport, msg: sink seq[T],
proc write*[T](transp: StreamTransport, msg: seq[T],
msglen = -1): Future[int] {.
async: (raw: true, raises: [TransportError, CancelledError]).} =
## Write sequence ``msg`` using transport ``transp``.
@ -2300,7 +2300,7 @@ proc write*[T](transp: StreamTransport, msg: sink seq[T],
let
written = nbytes - rbytes # In case fastWrite wrote some
var localCopy = chronosMoveSink(msg)
var localCopy = msg
retFuture.addCallback(proc(_: pointer) = reset(localCopy))
pbytes = cast[ptr byte](addr localCopy[written])