diff --git a/chronos/internal/asyncfutures.nim b/chronos/internal/asyncfutures.nim index 206f89c..49c6acd 100644 --- a/chronos/internal/asyncfutures.nim +++ b/chronos/internal/asyncfutures.nim @@ -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()) diff --git a/chronos/streams/asyncstream.nim b/chronos/streams/asyncstream.nim index e688f28..3d2f858 100644 --- a/chronos/streams/asyncstream.nim +++ b/chronos/streams/asyncstream.nim @@ -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) diff --git a/chronos/streams/tlsstream.nim b/chronos/streams/tlsstream.nim index 6c019f1..86f6d4c 100644 --- a/chronos/streams/tlsstream.nim +++ b/chronos/streams/tlsstream.nim @@ -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: diff --git a/chronos/transports/datagram.nim b/chronos/transports/datagram.nim index cd335df..f89a6b4 100644 --- a/chronos/transports/datagram.nim +++ b/chronos/transports/datagram.nim @@ -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, diff --git a/chronos/transports/stream.nim b/chronos/transports/stream.nim index fa3cbac..c80d992 100644 --- a/chronos/transports/stream.nim +++ b/chronos/transports/stream.nim @@ -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])