diff options
author | Heather Miller <heather.miller@epfl.ch> | 2012-01-19 09:26:40 +0100 |
---|---|---|
committer | Heather Miller <heather.miller@epfl.ch> | 2012-01-19 09:26:40 +0100 |
commit | 62bfdb1c8d4d508b976c2ab6ffdae98e35bd4b76 (patch) | |
tree | 349feb3c6483db483330336336896779292e9a1b /src/library/scala/concurrent/Future.scala | |
parent | 51a930f8595049babf5cf625e5f010c60bedc53b (diff) | |
download | scala-62bfdb1c8d4d508b976c2ab6ffdae98e35bd4b76.tar.gz scala-62bfdb1c8d4d508b976c2ab6ffdae98e35bd4b76.tar.bz2 scala-62bfdb1c8d4d508b976c2ab6ffdae98e35bd4b76.zip |
Added implementations for any and find on collections of futures.
Diffstat (limited to 'src/library/scala/concurrent/Future.scala')
-rw-r--r-- | src/library/scala/concurrent/Future.scala | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/library/scala/concurrent/Future.scala b/src/library/scala/concurrent/Future.scala index 6b358e1e09..468683dcde 100644 --- a/src/library/scala/concurrent/Future.scala +++ b/src/library/scala/concurrent/Future.scala @@ -355,7 +355,8 @@ self => p.future } - + +/* /** Creates a new future which holds the result of either this future or `that` future, depending on * which future was completed first. * @@ -377,14 +378,16 @@ self => case Right(v) => p trySuccess v } this onComplete completePromise - this onComplete completePromise + that onComplete completePromise p.future } - + +*/ } + /** TODO some docs * * @define nonDeterministic @@ -393,13 +396,17 @@ self => object Future { // TODO make more modular by encoding all other helper methods within the execution context - /** + /** TODO some docs */ def all[T, Coll[X] <: Traversable[X]](futures: Coll[Future[T]])(implicit cbf: CanBuildFrom[Coll[_], T, Coll[T]], ec: ExecutionContext): Future[Coll[T]] = ec.futureUtilities.all[T, Coll](futures) // move this to future companion object @inline def apply[T](body: =>T)(implicit executor: ExecutionContext): Future[T] = executor.future(body) + + def any[T](futures: Traversable[Future[T]])(implicit ec: ExecutionContext): Future[T] = ec.futureUtilities.any(futures) + + def find[T](futures: Traversable[Future[T]])(predicate: T => Boolean)(implicit ec: ExecutionContext): Future[Option[T]] = ec.futureUtilities.find(futures)(predicate) } |