stdlib: asyncdispatch: add proc supports varargs now.
This commit is contained in:
parent
5a007a84fc
commit
6e8053853b
1 changed files with 3 additions and 6 deletions
|
|
@ -355,7 +355,7 @@ proc `or`*[T, Y](fut1: Future[T], fut2: Future[Y]): Future[void] =
|
||||||
fut2.callback = cb
|
fut2.callback = cb
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc all*[A](futs: openarray[Future[A]]): Future[seq[A]] =
|
proc all*[T](futs: varargs[Future[T]]): Future[seq[T]] =
|
||||||
## Returns a future which will complete once all futures in ``futs``
|
## Returns a future which will complete once all futures in ``futs``
|
||||||
## complete.
|
## complete.
|
||||||
##
|
##
|
||||||
|
|
@ -364,12 +364,12 @@ proc all*[A](futs: openarray[Future[A]]): Future[seq[A]] =
|
||||||
|
|
||||||
var
|
var
|
||||||
retFuture = newFuture[seq[A]]("asyncdispatch.all")
|
retFuture = newFuture[seq[A]]("asyncdispatch.all")
|
||||||
retValues = newSeq[A](len(futs))
|
retValues = newSeq[T](len(futs))
|
||||||
completedFutures = 0
|
completedFutures = 0
|
||||||
|
|
||||||
for i, fut in futs:
|
for i, fut in futs:
|
||||||
proc setCallback(i: int) =
|
proc setCallback(i: int) =
|
||||||
fut.callback = proc(f: Future[A]) =
|
fut.callback = proc(f: Future[T]) =
|
||||||
retValues[i] = f.read()
|
retValues[i] = f.read()
|
||||||
inc(completedFutures)
|
inc(completedFutures)
|
||||||
|
|
||||||
|
|
@ -380,9 +380,6 @@ proc all*[A](futs: openarray[Future[A]]): Future[seq[A]] =
|
||||||
|
|
||||||
return retFuture
|
return retFuture
|
||||||
|
|
||||||
proc all*[A](futs: varargs[Future[A]]): Future[seq[A]] =
|
|
||||||
return all(@futs)
|
|
||||||
|
|
||||||
type
|
type
|
||||||
PDispatcherBase = ref object of RootRef
|
PDispatcherBase = ref object of RootRef
|
||||||
timers: HeapQueue[tuple[finishAt: float, fut: Future[void]]]
|
timers: HeapQueue[tuple[finishAt: float, fut: Future[void]]]
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue