Package co.paralleluniverse.actors

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


                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

                a.sendSync(message);
        }

        @Override
        public boolean send(Message message, long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException {
            final ActorRef a = getActor();
            if (a != null)
                return a.send(message, timeout, unit);
            return true;
        }
View Full Code Here

            return send(msg, timeout.nanosLeft(), TimeUnit.NANOSECONDS);
        }

        @Override
        public boolean trySend(Message message) {
            final ActorRef a = getActor();
            if (a != null)
                return a.trySend(message);
            return true;
        }
View Full Code Here

    @Override
    public void onOpen(Session session, EndpointConfig config) {
        if (this.config == null)
            this.config = config;
        ActorRef webActor = getHttpSessionActor(config).getWebActor();
        if (webActor != null) {
            WebSocketActorRef wsa = attachWebActor(session, config, webActor);
            wsa.onOpen();
        } else {
            try {
View Full Code Here

        }
    }

    private ChildEntry addChild1(ChildSpec spec) {
        LOG.debug("Adding child {}", spec);
        ActorRef actor = null;
        if (spec.builder instanceof ActorRef) {
            actor = (ActorRef) spec.builder;
            if (findEntry(actor) != null)
                throw new SupervisorException("Supervisor " + this + " already supervises actor " + actor);
        }

        Object id = spec.getId();
        if (id == null && actor != null)
            id = actor.getName();
        if (id != null && findEntryById(id) != null)
            throw new SupervisorException("Supervisor " + this + " already supervises an actor by the name " + id);
        final ChildEntry child = new ChildEntry(spec, actor);
        children.add(child);
        if (id != null)
View Full Code Here

        boolean handled = false;
        try {
            if (m instanceof ExitMessage) {
                final ExitMessage death = (ExitMessage) m;
                if (death.getWatch() != null) {
                    final ActorRef actor = death.actor;
                    final ChildEntry child = findEntry(actor);

                    if (child != null) {
                        LOG.info("Detected child death: " + child + ". cause: ", death.cause);
                        if (!restartStrategy.onChildDeath(this, child, death.cause)) {
View Full Code Here

                    return true;
                }
            // fall through
            case PERMANENT:
                LOG.info("Supervisor trying to restart child {}. (cause: {})", child, cause);
                final ActorRef actor = child.actor;
                shutdownChild(child, true);
                child.restartHistory.addRestart(now);
                final int numRestarts = child.restartHistory.numRestarts(now - child.spec.unit.toMillis(child.spec.duration));
                if (LOG.isDebugEnabled())
                    LOG.debug("Child {} has been restarted {} times in the last {} {}s", child, numRestarts, child.spec.duration, child.spec.unit);
View Full Code Here

                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

            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

TOP

Related Classes of co.paralleluniverse.actors.ActorRef

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.