Package akka.dispatch

Examples of akka.dispatch.Future


        counter.tell("tick");
        counter.tell("tick");
        counter.tell("tick");

        Future future = ask(counter, "get", 5000);

        future.onSuccess(new OnSuccess<Integer>() {
            public void onSuccess(Integer count) {
                System.out.println("Count is " + count);
            }
        });
View Full Code Here


  @SuppressWarnings("unchecked")
  public static class AsyncFutureActor extends UntypedActor {
    @Override
    public void onReceive(Object message) throws Exception {
      if (message instanceof ActorRef) {
        Future future = ((ActorRef) message).sendRequestReplyFuture("Hello from AsyncFutureActor!", 1000, getContext());
        future.onComplete(new Procedure<Future>() {
          public void apply(Future future) {
            log().logger().info("Result was " + future.result().get());
          }
        });
      }
    }
View Full Code Here

        counters.get(0).sendOneWay(message);
        try {
            incrementLatch.await(timeout, TimeUnit.SECONDS);
        } catch (InterruptedException exception) {}
        for (ActorRef counter : counters) {
            Future future = counter.sendRequestReplyFuture("GetCount");
            future.await();
            if (future.isCompleted()) {
                Option resultOption = future.result();
                if (resultOption.isDefined()) {
                    Object result = resultOption.get();
                    int count = (Integer) result;
                    assertEquals(1, count);
                }
View Full Code Here

        counter1.sendOneWay(new Coordinated(new Increment(counter2)));

        Thread.sleep(3000);

        Future future1 = counter1.sendRequestReplyFuture("GetCount");
        Future future2 = counter2.sendRequestReplyFuture("GetCount");

        future1.await();
        if (future1.isCompleted()) {
            if (future1.result().isDefined()) {
                int result = (Integer) future1.result().get();
                System.out.println("counter 1: " + result);
            }
        }

        future2.await();
        if (future2.isCompleted()) {
            if (future2.result().isDefined()) {
                int result = (Integer) future2.result().get();
                System.out.println("counter 2: " + result);
            }
        }

        counter1.stop();
View Full Code Here

        actors.get(0).sendOneWay(message);
        try {
            incrementLatch.await(timeout, TimeUnit.SECONDS);
        } catch (InterruptedException exception) {}
        for (ActorRef counter : counters) {
            Future future = counter.sendRequestReplyFuture("GetCount");
            future.await();
            if (future.isCompleted()) {
                Option resultOption = future.result();
                if (resultOption.isDefined()) {
                    Object result = resultOption.get();
                    int count = (Integer) result;
                    assertEquals(0, count);
                }
View Full Code Here

        counter1.sendOneWay(new Increment(counter2));

        Thread.sleep(3000);

        Future future1 = counter1.sendRequestReplyFuture("GetCount");
        Future future2 = counter2.sendRequestReplyFuture("GetCount");

        future1.await();
        if (future1.isCompleted()) {
            if (future1.result().isDefined()) {
                int result = (Integer) future1.result().get();
                System.out.println("counter 1: " + result);
            }
        }

        future2.await();
        if (future2.isCompleted()) {
            if (future2.result().isDefined()) {
                int result = (Integer) future2.result().get();
                System.out.println("counter 2: " + result);
            }
        }

        counter1.stop();
View Full Code Here

        counters.get(0).sendOneWay(new Coordinated(message));
        try {
            incrementLatch.await(timeout, TimeUnit.SECONDS);
        } catch (InterruptedException exception) {}
        for (ActorRef counter : counters) {
            Future future = counter.sendRequestReplyFuture("GetCount");
            future.await();
            if (future.isCompleted()) {
                Option resultOption = future.result();
                if (resultOption.isDefined()) {
                    Object result = resultOption.get();
                    int count = (Integer) result;
                    assertEquals(1, count);
                }
View Full Code Here

        actors.get(0).sendOneWay(new Coordinated(message));
        try {
            incrementLatch.await(timeout, TimeUnit.SECONDS);
        } catch (InterruptedException exception) {}
        for (ActorRef counter : counters) {
            Future future = counter.sendRequestReplyFuture("GetCount");
            future.await();
            if (future.isCompleted()) {
                Option resultOption = future.result();
                if (resultOption.isDefined()) {
                    Object result = resultOption.get();
                    int count = (Integer) result;
                    assertEquals(0, count);
                }
View Full Code Here

TOP

Related Classes of akka.dispatch.Future

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.