Removing ExecutionContext from some signatures in Future.scala, changing copyright to Akka for BatchingExecutor
This commit is contained in:
parent
f3078263bc
commit
94e8d201f0
3 changed files with 22 additions and 23 deletions
|
|
@ -64,7 +64,7 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToExecuteAnOnResultCallback() throws Throwable {
|
public void mustBeAbleToExecuteAnOnResultCallback() throws Throwable {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Promise<String> cf = Futures.promise(system.dispatcher());
|
Promise<String> cf = Futures.promise();
|
||||||
Future<String> f = cf.future();
|
Future<String> f = cf.future();
|
||||||
f.onSuccess(new OnSuccess<String>() {
|
f.onSuccess(new OnSuccess<String>() {
|
||||||
public void onSuccess(String result) {
|
public void onSuccess(String result) {
|
||||||
|
|
@ -81,7 +81,7 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToExecuteAnOnExceptionCallback() throws Throwable {
|
public void mustBeAbleToExecuteAnOnExceptionCallback() throws Throwable {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Promise<String> cf = Futures.promise(system.dispatcher());
|
Promise<String> cf = Futures.promise();
|
||||||
Future<String> f = cf.future();
|
Future<String> f = cf.future();
|
||||||
f.onFailure(new OnFailure() {
|
f.onFailure(new OnFailure() {
|
||||||
public void onFailure(Throwable t) {
|
public void onFailure(Throwable t) {
|
||||||
|
|
@ -99,7 +99,7 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToExecuteAnOnCompleteCallback() throws Throwable {
|
public void mustBeAbleToExecuteAnOnCompleteCallback() throws Throwable {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Promise<String> cf = Futures.promise(system.dispatcher());
|
Promise<String> cf = Futures.promise();
|
||||||
Future<String> f = cf.future();
|
Future<String> f = cf.future();
|
||||||
f.onComplete(new OnComplete<String>() {
|
f.onComplete(new OnComplete<String>() {
|
||||||
public void onComplete(Throwable t, String r) {
|
public void onComplete(Throwable t, String r) {
|
||||||
|
|
@ -115,7 +115,7 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToForeachAFuture() throws Throwable {
|
public void mustBeAbleToForeachAFuture() throws Throwable {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Promise<String> cf = Futures.promise(system.dispatcher());
|
Promise<String> cf = Futures.promise();
|
||||||
Future<String> f = cf.future();
|
Future<String> f = cf.future();
|
||||||
f.foreach(new Foreach<String>() {
|
f.foreach(new Foreach<String>() {
|
||||||
public void each(String future) {
|
public void each(String future) {
|
||||||
|
|
@ -131,14 +131,14 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToFlatMapAFuture() throws Throwable {
|
public void mustBeAbleToFlatMapAFuture() throws Throwable {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Promise<String> cf = Futures.promise(system.dispatcher());
|
Promise<String> cf = Futures.promise();
|
||||||
cf.success("1000");
|
cf.success("1000");
|
||||||
Future<String> f = cf.future();
|
Future<String> f = cf.future();
|
||||||
Future<Integer> r = f.flatMap(new Mapper<String, Future<Integer>>() {
|
Future<Integer> r = f.flatMap(new Mapper<String, Future<Integer>>() {
|
||||||
public Future<Integer> checkedApply(String r) throws Throwable {
|
public Future<Integer> checkedApply(String r) throws Throwable {
|
||||||
if (false) throw new IOException("Just here to make sure this compiles.");
|
if (false) throw new IOException("Just here to make sure this compiles.");
|
||||||
latch.countDown();
|
latch.countDown();
|
||||||
Promise<Integer> cf = Futures.promise(system.dispatcher());
|
Promise<Integer> cf = Futures.promise();
|
||||||
cf.success(Integer.parseInt(r));
|
cf.success(Integer.parseInt(r));
|
||||||
return cf.future();
|
return cf.future();
|
||||||
}
|
}
|
||||||
|
|
@ -152,7 +152,7 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void mustBeAbleToFilterAFuture() throws Throwable {
|
public void mustBeAbleToFilterAFuture() throws Throwable {
|
||||||
final CountDownLatch latch = new CountDownLatch(1);
|
final CountDownLatch latch = new CountDownLatch(1);
|
||||||
Promise<String> cf = Futures.promise(system.dispatcher());
|
Promise<String> cf = Futures.promise();
|
||||||
Future<String> f = cf.future();
|
Future<String> f = cf.future();
|
||||||
Future<String> r = f.filter(Filter.filterOf(new Function<String, Boolean>() {
|
Future<String> r = f.filter(Filter.filterOf(new Function<String, Boolean>() {
|
||||||
public Boolean apply(String r) {
|
public Boolean apply(String r) {
|
||||||
|
|
@ -280,7 +280,7 @@ public class JavaFutureTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void blockMustBeCallable() throws Exception {
|
public void blockMustBeCallable() throws Exception {
|
||||||
Promise<String> p = Futures.promise(system.dispatcher());
|
Promise<String> p = Futures.promise();
|
||||||
Duration d = Duration.create(1, TimeUnit.SECONDS);
|
Duration d = Duration.create(1, TimeUnit.SECONDS);
|
||||||
p.success("foo");
|
p.success("foo");
|
||||||
Await.ready(p.future(), d);
|
Await.ready(p.future(), d);
|
||||||
|
|
@ -289,7 +289,7 @@ public class JavaFutureTests {
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void mapToMustBeCallable() throws Exception {
|
public void mapToMustBeCallable() throws Exception {
|
||||||
Promise<Object> p = Futures.promise(system.dispatcher());
|
Promise<Object> p = Futures.promise();
|
||||||
Future<String> f = p.future().mapTo(classTag(String.class));
|
Future<String> f = p.future().mapTo(classTag(String.class));
|
||||||
Duration d = Duration.create(1, TimeUnit.SECONDS);
|
Duration d = Duration.create(1, TimeUnit.SECONDS);
|
||||||
p.success("foo");
|
p.success("foo");
|
||||||
|
|
@ -300,7 +300,7 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void recoverToMustBeCallable() throws Exception {
|
public void recoverToMustBeCallable() throws Exception {
|
||||||
final IllegalStateException fail = new IllegalStateException("OHNOES");
|
final IllegalStateException fail = new IllegalStateException("OHNOES");
|
||||||
Promise<Object> p = Futures.promise(system.dispatcher());
|
Promise<Object> p = Futures.promise();
|
||||||
Future<Object> f = p.future().recover(new Recover<Object>() {
|
Future<Object> f = p.future().recover(new Recover<Object>() {
|
||||||
public Object recover(Throwable t) throws Throwable {
|
public Object recover(Throwable t) throws Throwable {
|
||||||
if (t == fail)
|
if (t == fail)
|
||||||
|
|
@ -317,11 +317,11 @@ public class JavaFutureTests {
|
||||||
@Test
|
@Test
|
||||||
public void recoverWithToMustBeCallable() throws Exception{
|
public void recoverWithToMustBeCallable() throws Exception{
|
||||||
final IllegalStateException fail = new IllegalStateException("OHNOES");
|
final IllegalStateException fail = new IllegalStateException("OHNOES");
|
||||||
Promise<Object> p = Futures.promise(system.dispatcher());
|
Promise<Object> p = Futures.promise();
|
||||||
Future<Object> f = p.future().recoverWith(new Recover<Future<Object>>() {
|
Future<Object> f = p.future().recoverWith(new Recover<Future<Object>>() {
|
||||||
public Future<Object> recover(Throwable t) throws Throwable {
|
public Future<Object> recover(Throwable t) throws Throwable {
|
||||||
if (t == fail)
|
if (t == fail)
|
||||||
return Futures.<Object> successful("foo", system.dispatcher());
|
return Futures.<Object>successful("foo");
|
||||||
else
|
else
|
||||||
throw t;
|
throw t;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1,10 +1,6 @@
|
||||||
/* __ *\
|
/**
|
||||||
** ________ ___ / / ___ Scala API **
|
* Copyright (C) 2009-2012 Typesafe Inc. <http://www.typesafe.com>
|
||||||
** / __/ __// _ | / / / _ | (c) 2003-2011, LAMP/EPFL **
|
*/
|
||||||
** __\ \/ /__/ __ |/ /__/ __ | http://scala-lang.org/ **
|
|
||||||
** /____/\___/_/ |_/____/_/ | | **
|
|
||||||
** |/ **
|
|
||||||
\* */
|
|
||||||
|
|
||||||
package akka.dispatch
|
package akka.dispatch
|
||||||
|
|
||||||
|
|
@ -41,6 +37,9 @@ private[akka] trait Batchable extends Runnable
|
||||||
* on the outer task completing.
|
* on the outer task completing.
|
||||||
* This executor may run tasks in any order, including LIFO order.
|
* This executor may run tasks in any order, including LIFO order.
|
||||||
* There are no ordering guarantees.
|
* 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 {
|
private[akka] trait BatchingExecutor extends Executor {
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,22 +19,22 @@ object Futures {
|
||||||
/**
|
/**
|
||||||
* Java API, equivalent to Future.apply
|
* 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
|
* 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
|
* 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
|
* 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.
|
* Java API.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue