@@ -133,8 +133,8 @@ trait Future[+T] extends Awaitable[T] {
133133 * $multipleCallbacks
134134 * $callbackInContext
135135 */
136- def onFailure [U ](callback : PartialFunction [Throwable , U ])(implicit executor : ExecutionContext ): Unit = onComplete {
137- case Failure (t) if NonFatal (t) && callback .isDefinedAt(t) => callback (t)
136+ def onFailure [U ](@ deprecatedName( ' callback ) pf : PartialFunction [Throwable , U ])(implicit executor : ExecutionContext ): Unit = onComplete {
137+ case Failure (t) if NonFatal (t) && pf .isDefinedAt(t) => pf (t)
138138 case _ =>
139139 }(executor)
140140
@@ -147,7 +147,7 @@ trait Future[+T] extends Awaitable[T] {
147147 * $multipleCallbacks
148148 * $callbackInContext
149149 */
150- def onComplete [U ](func : Try [T ] => U )(implicit executor : ExecutionContext ): Unit
150+ def onComplete [U ](@ deprecatedName( ' func ) f : Try [T ] => U )(implicit executor : ExecutionContext ): Unit
151151
152152
153153 /* Miscellaneous */
@@ -303,21 +303,21 @@ trait Future[+T] extends Awaitable[T] {
303303 * Await.result(h, Duration.Zero) // throw a NoSuchElementException
304304 * }}}
305305 */
306- def filter (pred : T => Boolean )(implicit executor : ExecutionContext ): Future [T ] = {
307- val p = Promise [T ]()
306+ def filter (@ deprecatedName( ' pred ) p : T => Boolean )(implicit executor : ExecutionContext ): Future [T ] = {
307+ val promise = Promise [T ]()
308308
309309 onComplete {
310- case f : Failure [_] => p complete f.asInstanceOf [Failure [T ]]
310+ case f : Failure [_] => promise complete f.asInstanceOf [Failure [T ]]
311311 case Success (v) =>
312312 try {
313- if (pred (v)) p success v
314- else p failure new NoSuchElementException (" Future.filter predicate is not satisfied" )
313+ if (p (v)) promise success v
314+ else promise failure new NoSuchElementException (" Future.filter predicate is not satisfied" )
315315 } catch {
316- case NonFatal (t) => p failure t
316+ case NonFatal (t) => promise failure t
317317 }
318318 }(executor)
319319
320- p .future
320+ promise .future
321321 }
322322
323323 /** Used by for-comprehensions.
@@ -565,16 +565,16 @@ object Future {
565565 *
566566 * @tparam T the type of the result
567567 * @param body the asychronous computation
568- * @param execctx the execution context on which the future is run
568+ * @param executor the execution context on which the future is run
569569 * @return the `Future` holding the result of the computation
570570 */
571- def apply [T ](body : => T )(implicit execctx : ExecutionContext ): Future [T ] = impl.Future (body)
571+ def apply [T ](body : => T )(implicit @ deprecatedName( ' execctx ) executor : ExecutionContext ): Future [T ] = impl.Future (body)
572572
573573 /** Simple version of `Futures.traverse`. Transforms a `TraversableOnce[Future[A]]` into a `Future[TraversableOnce[A]]`.
574574 * Useful for reducing many `Future`s into a single `Future`.
575575 */
576576 def sequence [A , M [_] <: TraversableOnce [_]](in : M [Future [A ]])(implicit cbf : CanBuildFrom [M [Future [A ]], A , M [A ]], executor : ExecutionContext ): Future [M [A ]] = {
577- in.foldLeft(Promise . successful(cbf(in)).future ) {
577+ in.foldLeft(successful(cbf(in))) {
578578 (fr, fa) => for (r <- fr; a <- fa.asInstanceOf [Future [A ]]) yield (r += a)
579579 } map (_.result())
580580 }
@@ -592,15 +592,15 @@ object Future {
592592
593593 /** Returns a `Future` that will hold the optional result of the first `Future` with a result that matches the predicate.
594594 */
595- def find [T ](futurestravonce : TraversableOnce [Future [T ]])(predicate : T => Boolean )(implicit executor : ExecutionContext ): Future [Option [T ]] = {
596- val futures = futurestravonce .toBuffer
597- if (futures .isEmpty) Promise . successful[Option [T ]](None ).future
595+ def find [T ](@ deprecatedName( ' futurestravonce ) futures : TraversableOnce [Future [T ]])(@ deprecatedName( ' predicate ) p : T => Boolean )(implicit executor : ExecutionContext ): Future [Option [T ]] = {
596+ val futuresBuffer = futures .toBuffer
597+ if (futuresBuffer .isEmpty) successful[Option [T ]](None )
598598 else {
599599 val result = Promise [Option [T ]]()
600- val ref = new AtomicInteger (futures .size)
600+ val ref = new AtomicInteger (futuresBuffer .size)
601601 val search : Try [T ] => Unit = v => try {
602602 v match {
603- case Success (r) => if (predicate(r)) result tryComplete Success (Some (r))
603+ case Success (r) if p(r) => result tryComplete Success (Some (r))
604604 case _ =>
605605 }
606606 } finally {
@@ -609,7 +609,7 @@ object Future {
609609 }
610610 }
611611
612- futures .foreach(_ onComplete search)
612+ futuresBuffer .foreach(_ onComplete search)
613613
614614 result.future
615615 }
@@ -625,9 +625,9 @@ object Future {
625625 * val result = Await.result(Future.fold(futures)(0)(_ + _), 5 seconds)
626626 * }}}
627627 */
628- def fold [T , R ](futures : TraversableOnce [Future [T ]])(zero : R )(foldFun : (R , T ) => R )(implicit executor : ExecutionContext ): Future [R ] = {
629- if (futures.isEmpty) Promise . successful(zero).future
630- else sequence(futures).map(_.foldLeft(zero)(foldFun ))
628+ def fold [T , R ](futures : TraversableOnce [Future [T ]])(zero : R )(@ deprecatedName( ' foldFun ) op : (R , T ) => R )(implicit executor : ExecutionContext ): Future [R ] = {
629+ if (futures.isEmpty) successful(zero)
630+ else sequence(futures).map(_.foldLeft(zero)(op ))
631631 }
632632
633633 /** Initiates a fold over the supplied futures where the fold-zero is the result value of the `Future` that's completed first.
@@ -638,7 +638,7 @@ object Future {
638638 * }}}
639639 */
640640 def reduce [T , R >: T ](futures : TraversableOnce [Future [T ]])(op : (R , T ) => R )(implicit executor : ExecutionContext ): Future [R ] = {
641- if (futures.isEmpty) Promise [ R ]().failure( new NoSuchElementException (" reduce attempted on empty collection" )).future
641+ if (futures.isEmpty) failed( new NoSuchElementException (" reduce attempted on empty collection" ))
642642 else sequence(futures).map(_ reduceLeft op)
643643 }
644644
@@ -651,7 +651,7 @@ object Future {
651651 * }}}
652652 */
653653 def traverse [A , B , M [_] <: TraversableOnce [_]](in : M [A ])(fn : A => Future [B ])(implicit cbf : CanBuildFrom [M [A ], B , M [B ]], executor : ExecutionContext ): Future [M [B ]] =
654- in.foldLeft(Promise . successful(cbf(in)).future ) { (fr, a) =>
654+ in.foldLeft(successful(cbf(in))) { (fr, a) =>
655655 val fb = fn(a.asInstanceOf [A ])
656656 for (r <- fr; b <- fb) yield (r += b)
657657 }.map(_.result())
0 commit comments