Examples of ActorRef


Examples of co.paralleluniverse.actors.ActorRef

                throw new AssertionError();
        }
    }

    private ActorRef<?> start(ChildEntry child) {
        final ActorRef old = child.actor;
        if (old != null && !LocalActorUtil.isDone(old))
            throw new IllegalStateException("Actor " + child.actor + " cannot be restarted because it is not dead");

        final Actor actor = child.spec.builder.build();
        if (actor.getName() == null && child.spec.id != null)
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

            child.actor = null;
        }
    }

    private boolean joinChild(ChildEntry child) throws InterruptedException {
        final ActorRef actor = child.actor;

        LOG.debug("Joining child {}", child);
        if (child.actor != null) {
            try {
                LocalActorUtil.join(actor, child.spec.shutdownDeadline, TimeUnit.MILLISECONDS);
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

    public static <V> void replyError(GenRequestMessage req, Throwable e) throws SuspendExecution {
        req.getFrom().send(new GenErrorResponseMessage(req.getId(), e));
    }

    private static ActorRef getCurrentActor() {
        ActorRef actorRef = ActorRef.self();
        if (actorRef == null) {
            // create a "dummy actor" on the current strand
            Actor actor = new Actor(Strand.currentStrand(), null, new MailboxConfig(5, OverflowPolicy.THROW)) {
                @Override
                protected Object doRun() throws InterruptedException, SuspendExecution {
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

            this.actor = null;
            this.done = true;
        }

        private ActorRef getActor() {
            ActorRef a = null;
            if (actor != null)
                a = actor.get().ref();
            return a;
        }
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

                a = actor.get().ref();
            return a;
        }

        private ActorRef actor() {
            final ActorRef a = getActor();
            if (a == null)
                throw new RuntimeException("Temporary actor is out of scope");
            return a;
        }
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

            return actor().getName();
        }

        @Override
        public void interrupt() {
            final ActorRef a = getActor();
            if (a != null)
                a.interrupt();
        }
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

                a.interrupt();
        }

        @Override
        public void send(Message message) throws SuspendExecution {
            final ActorRef a = getActor();
            if (a != null)
                a.send(message);
        }
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

                a.send(message);
        }

        @Override
        public void sendSync(Message message) throws SuspendExecution {
            final ActorRef a = getActor();
            if (a != null)
                a.sendSync(message);
        }
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

    }

    @Override
    public <Message> ActorRef<Message> getActor(String name) throws SuspendExecution {
        final String rootName = name;
        ActorRef cacheValue = rootCache.get(rootName);
        if (cacheValue != null)
            return cacheValue;
        serlock.lock();
        try {
            cacheValue = rootCache.get(rootName);
View Full Code Here

Examples of co.paralleluniverse.actors.ActorRef

        System.setProperty("galaxy.slave_port", Integer.toString(8050 + nodeId));

        ActorRef<Message> ping = new BasicActor<Message, Void>() {
            @Override
            protected Void doRun() throws InterruptedException, SuspendExecution {
                ActorRef pong;
                while ((pong = ActorRegistry.getActor("pong")) == null) {
                    System.out.println("waiting for pong");
                    Strand.sleep(3000);
                }
                System.out.println("pong is " + pong);

                for (int i = 0; i < 3; i++) {
                    pong.send(new Message(self(), PING));
                    Message msg = receive();
                    System.out.println("ping received " + msg.type);
                }

                pong.send(new Message(null, FINISHED));
                return null;
            }
        }.spawn();
        LocalActor.join(ping);
        System.out.println("finished ping");
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.