diff --git a/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java b/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java index 5691069bd0..c092ccceb2 100644 --- a/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java +++ b/akka-actor-tests/src/test/java/akka/dispatch/JavaFutureTests.java @@ -64,7 +64,7 @@ public class JavaFutureTests { @Test public void mustBeAbleToExecuteAnOnResultCallback() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); Future f = cf.future(); f.onSuccess(new OnSuccess() { public void onSuccess(String result) { @@ -81,7 +81,7 @@ public class JavaFutureTests { @Test public void mustBeAbleToExecuteAnOnExceptionCallback() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); Future f = cf.future(); f.onFailure(new OnFailure() { public void onFailure(Throwable t) { @@ -99,7 +99,7 @@ public class JavaFutureTests { @Test public void mustBeAbleToExecuteAnOnCompleteCallback() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); Future f = cf.future(); f.onComplete(new OnComplete() { public void onComplete(Throwable t, String r) { @@ -115,7 +115,7 @@ public class JavaFutureTests { @Test public void mustBeAbleToForeachAFuture() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); Future f = cf.future(); f.foreach(new Foreach() { public void each(String future) { @@ -131,14 +131,14 @@ public class JavaFutureTests { @Test public void mustBeAbleToFlatMapAFuture() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); cf.success("1000"); Future f = cf.future(); Future r = f.flatMap(new Mapper>() { public Future checkedApply(String r) throws Throwable { if (false) throw new IOException("Just here to make sure this compiles."); latch.countDown(); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); cf.success(Integer.parseInt(r)); return cf.future(); } @@ -152,7 +152,7 @@ public class JavaFutureTests { @Test public void mustBeAbleToFilterAFuture() throws Throwable { final CountDownLatch latch = new CountDownLatch(1); - Promise cf = Futures.promise(system.dispatcher()); + Promise cf = Futures.promise(); Future f = cf.future(); Future r = f.filter(Filter.filterOf(new Function() { public Boolean apply(String r) { @@ -280,7 +280,7 @@ public class JavaFutureTests { @Test public void blockMustBeCallable() throws Exception { - Promise p = Futures.promise(system.dispatcher()); + Promise p = Futures.promise(); Duration d = Duration.create(1, TimeUnit.SECONDS); p.success("foo"); Await.ready(p.future(), d); @@ -289,7 +289,7 @@ public class JavaFutureTests { @Test public void mapToMustBeCallable() throws Exception { - Promise p = Futures.promise(system.dispatcher()); + Promise p = Futures.promise(); Future f = p.future().mapTo(classTag(String.class)); Duration d = Duration.create(1, TimeUnit.SECONDS); p.success("foo"); @@ -300,7 +300,7 @@ public class JavaFutureTests { @Test public void recoverToMustBeCallable() throws Exception { final IllegalStateException fail = new IllegalStateException("OHNOES"); - Promise p = Futures.promise(system.dispatcher()); + Promise p = Futures.promise(); Future f = p.future().recover(new Recover() { public Object recover(Throwable t) throws Throwable { if (t == fail) @@ -317,11 +317,11 @@ public class JavaFutureTests { @Test public void recoverWithToMustBeCallable() throws Exception{ final IllegalStateException fail = new IllegalStateException("OHNOES"); - Promise p = Futures.promise(system.dispatcher()); + Promise p = Futures.promise(); Future f = p.future().recoverWith(new Recover>() { public Future recover(Throwable t) throws Throwable { if (t == fail) - return Futures. successful("foo", system.dispatcher()); + return Futures.successful("foo"); else throw t; } diff --git a/akka-actor/src/main/scala/akka/dispatch/BatchingExecutor.scala b/akka-actor/src/main/scala/akka/dispatch/BatchingExecutor.scala index 0622f80a3b..d0092d77e0 100644 --- a/akka-actor/src/main/scala/akka/dispatch/BatchingExecutor.scala +++ b/akka-actor/src/main/scala/akka/dispatch/BatchingExecutor.scala @@ -1,10 +1,6 @@ -/* __ *\ -** ________ ___ / / ___ Scala API ** -** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL ** -** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ ** -** /____/\___/_/ |_/____/_/ | | ** -** |/ ** -\* */ +/** + * Copyright (C) 2009-2012 Typesafe Inc. + */ package akka.dispatch @@ -41,6 +37,9 @@ private[akka] trait Batchable extends Runnable * on the outer task completing. * This executor may run tasks in any order, including LIFO order. * There are no ordering guarantees. + * + * WARNING: The underlying Executor's execute-method must not execute the submitted Runnable + * in the calling thread synchronously. It must enqueue/handoff the Runnable. */ private[akka] trait BatchingExecutor extends Executor { diff --git a/akka-actor/src/main/scala/akka/dispatch/Future.scala b/akka-actor/src/main/scala/akka/dispatch/Future.scala index c68049d8c4..14cb9c2014 100644 --- a/akka-actor/src/main/scala/akka/dispatch/Future.scala +++ b/akka-actor/src/main/scala/akka/dispatch/Future.scala @@ -19,22 +19,22 @@ object Futures { /** * Java API, equivalent to Future.apply */ - def future[T](body: Callable[T], executor: ExecutionContext): Future[T] = Future(body.call)(executor) // TODO REMOVE EC + def future[T](body: Callable[T], executor: ExecutionContext): Future[T] = Future(body.call)(executor) /** * Java API, equivalent to Promise.apply */ - def promise[T](executor: ExecutionContext): Promise[T] = Promise[T]() // TODO REMOVE EC + def promise[T](): Promise[T] = Promise[T]() /** * Java API, creates an already completed Promise with the specified exception */ - def failed[T](exception: Throwable, executor: ExecutionContext): Future[T] = Future.failed(exception) // TODO REMOVE EC + def failed[T](exception: Throwable): Future[T] = Future.failed(exception) /** * Java API, Creates an already completed Promise with the specified result */ - def successful[T](result: T, executor: ExecutionContext): Future[T] = Future.successful(result) // TODO REMOVE EC + def successful[T](result: T): Future[T] = Future.successful(result) /** * Java API.