Examples of atomic()


Examples of akka.transactor.Coordinated.atomic()

  public void onReceive(Object o) throws Exception {
    if (o instanceof Coordinated) {
      Coordinated coordinated = (Coordinated) o;
      final Object message = coordinated.getMessage();
      if (message instanceof AccountDebit) {
        coordinated.atomic(new Runnable() {
          public void run() {
            AccountDebit accDebit = (AccountDebit) message;
            //check for funds availability
            if (balance.get() > accDebit.getAmount()) {
              float bal = balance.get() - accDebit.getAmount();
View Full Code Here

Examples of akka.transactor.Coordinated.atomic()

            }
          }
        });

      } else if (message instanceof AccountCredit) {
        coordinated.atomic(new Runnable() {
          public void run() {
            AccountCredit accCredit = (AccountCredit) message;
            float bal = balance.get() + accCredit.getAmount();
            balance.set(bal);
          }
View Full Code Here

Examples of akka.transactor.Coordinated.atomic()

    if (message instanceof TransferMsg) {
      final TransferMsg transfer = (TransferMsg) message;
      final Coordinated coordinated = new Coordinated(timeout);

      coordinated.atomic(new Runnable() {
        public void run() {
          // credit amount - will always be successful
          to.tell(coordinated.coordinate(new AccountCredit(transfer
              .getAmtToBeTransferred())));
          // debit amount - throws an exception if funds insufficient
View Full Code Here

Examples of akka.transactor.Coordinated.atomic()

  public void onReceive(Object message) throws Exception {

    if (message instanceof TransferMsg) {
      final TransferMsg transfer = (TransferMsg) message;   
      final Coordinated coordinated = new Coordinated(timeout);
      coordinated.atomic(new Runnable() {
        public void run() {
          // credit amount - will always be successful
          to.tell(coordinated.coordinate(new AccountCredit(transfer
              .getAmtToBeTransferred())));
          // debit amount - throws an exception if funds insufficient
View Full Code Here

Examples of akka.transactor.Coordinated.atomic()

                final CountDownLatch latch = increment.getLatch();
                if (!friends.isEmpty()) {
                    Increment coordMessage = new Increment(friends.subList(1, friends.size()), latch);
                    friends.get(0).sendOneWay(coordinated.coordinate(coordMessage));
                }
                coordinated.atomic(new Atomically(txFactory) {
                    public void atomically() {
                        increment();
                        StmUtils.scheduleDeferredTask(new Runnable() {
                            public void run() { latch.countDown(); }
                        });
View Full Code Here

Examples of akka.transactor.Coordinated.atomic()

            if (message instanceof Increment) {
                Increment increment = (Increment) message;
                if (increment.hasFriend()) {
                    increment.getFriend().sendOneWay(coordinated.coordinate(new Increment()));
                }
                coordinated.atomic(new Atomically() {
                    public void atomically() {
                        increment();
                    }
                });
            }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.