parent
a5be5303e3
commit
48880c6e4e
|
@ -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)
|
||||
|
||||
|
|
|
@ -10,6 +10,8 @@
|
|||
import net, nativesockets, strutils
|
||||
import ../asyncloop
|
||||
|
||||
export net
|
||||
|
||||
const
|
||||
DefaultStreamBufferSize* = 4096 ## Default buffer size for stream
|
||||
## transports
|
||||
|
|
|
@ -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] =
|
||||
|
|
Loading…
Reference in New Issue