diff --git a/asyncdispatch2/asyncfutures2.nim b/asyncdispatch2/asyncfutures2.nim index 199d11b2..059869de 100644 --- a/asyncdispatch2/asyncfutures2.nim +++ b/asyncdispatch2/asyncfutures2.nim @@ -442,11 +442,12 @@ proc all*[T](futs: varargs[Future[T]]): auto = let totalFutures = len(futs) for fut in futs: - fut.addCallback proc (f: Future[T]) = + fut.addCallback proc (data: pointer) = + var fut = cast[FutureBase](data) inc(completedFutures) if not retFuture.finished: - if f.failed: - retFuture.fail(f.error) + if fut.failed: + retFuture.fail(fut.error) else: if completedFutures == totalFutures: retFuture.complete() @@ -464,14 +465,14 @@ proc all*[T](futs: varargs[Future[T]]): auto = for i, fut in futs: proc setCallback(i: int) = - fut.addCallback proc (f: Future[T]) = + fut.addCallback proc (data: pointer) = + var fut = cast[Future[T]](data) inc(completedFutures) if not retFuture.finished: - if f.failed: - retFuture.fail(f.error) + if fut.failed: + retFuture.fail(fut.error) else: - retValues[i] = f.read() - + retValues[i] = fut.read() if completedFutures == len(retValues): retFuture.complete(retValues) diff --git a/asyncdispatch2/transports/common.nim b/asyncdispatch2/transports/common.nim index f9eab5c4..f800bbed 100644 --- a/asyncdispatch2/transports/common.nim +++ b/asyncdispatch2/transports/common.nim @@ -10,6 +10,8 @@ import net, nativesockets, strutils import ../asyncloop +export net + const DefaultStreamBufferSize* = 4096 ## Default buffer size for stream ## transports diff --git a/asyncdispatch2/transports/stream.nim b/asyncdispatch2/transports/stream.nim index c78949c7..9e21a9e0 100644 --- a/asyncdispatch2/transports/stream.nim +++ b/asyncdispatch2/transports/stream.nim @@ -798,8 +798,9 @@ proc createStreamServer*[T](host: TransportAddress, result = createStreamServer(host, cbproc, flags, sock, backlog, bufferSize, cast[pointer](udata)) -proc getUserData*[T](server: StreamServer): ref T {.inline.} = - result = cast[ref T](server.udata) +proc getUserData*[T](server: StreamServer): T {.inline.} = + ## Obtain user data stored in ``server`` object. + result = cast[T](server.udata) proc write*(transp: StreamTransport, pbytes: pointer, nbytes: int): Future[int] =