Package co.paralleluniverse.strands

Examples of co.paralleluniverse.strands.Strand


     * @return the collection of strands
     */
    public final Collection<Strand> getQueuedStrands() {
        ArrayList<Strand> list = new ArrayList<Strand>();
        for (Node p = tail; p != null; p = p.prev) {
            Strand t = p.strand;
            if (t != null)
                list.add(t);
        }
        return list;
    }
View Full Code Here


     */
    public final Collection<Strand> getExclusiveQueuedStrands() {
        ArrayList<Strand> list = new ArrayList<Strand>();
        for (Node p = tail; p != null; p = p.prev) {
            if (!p.isShared()) {
                Strand t = p.strand;
                if (t != null)
                    list.add(t);
            }
        }
        return list;
View Full Code Here

     */
    public final Collection<Strand> getSharedQueuedStrands() {
        ArrayList<Strand> list = new ArrayList<Strand>();
        for (Node p = tail; p != null; p = p.prev) {
            if (p.isShared()) {
                Strand t = p.strand;
                if (t != null)
                    list.add(t);
            }
        }
        return list;
View Full Code Here

            if (!isHeldExclusively())
                throw new IllegalMonitorStateException();
            ArrayList<Strand> list = new ArrayList<Strand>();
            for (Node w = firstWaiter; w != null; w = w.nextWaiter) {
                if (w.waitStatus == Node.CONDITION) {
                    Strand t = w.strand;
                    if (t != null)
                        list.add(t);
                }
            }
            return list;
View Full Code Here

        return select(-1, null);
    }

    @Override
    public Object register() {
        Strand s = Strand.currentStrand();
        if (waiter != null && !waiter.equals(s))
            throw new IllegalMonitorStateException("A strand is already registered");
        this.waiter = Strand.currentStrand();

        final int n = actions.size();
View Full Code Here

    @Override
    public String toString() {
        String className = getClass().getSimpleName();
        if (className.isEmpty())
            className = getClass().getName().substring(getClass().getPackage().getName().length() + 1);
        final Strand strand = runner.getStrand();
        final String strandName = (strand != null ? strand.getName() : "null"); // strand.getClass().getSimpleName() + '@' + strand.getId()
        return className + "@"
                + (getName() != null ? getName() : Integer.toHexString(System.identityHashCode(this)))
                + "[owner: " + strandName + ']';
    }
View Full Code Here

    //<editor-fold desc="Lifecycle">
    /////////// Lifecycle ///////////////////////////////////
    final V run0() throws InterruptedException, SuspendExecution {
        JMXActorsMonitor.getInstance().actorStarted(ref);
        final Strand strand = runner.getStrand(); // runner might be nulled by running actor
        if (!strand.isFiber())
            currentActor.set(this);
        try {
            if (this instanceof MigratingActor && globalId == null)
                this.globalId = MigrationService.registerMigratingActor();

            result = doRun();
            die(null);
            return result;
        } catch (ActorAbort abort) {
            throw abort;
        } catch (InterruptedException e) {
            if (this.exception != null) {
                die(exception);
                throw (RuntimeException) exception;
            }
            die(e);
            throw e;
        } catch (Throwable t) {
            if (t.getCause() instanceof InterruptedException) {
                InterruptedException ie = (InterruptedException) t.getCause();
                if (this.exception != null) {
                    die(exception);
                    throw (RuntimeException) exception;
                }
                die(ie);
                throw ie;
            }
            this.exception = t;
            die(t);
            throw t;
        } finally {
            record(1, "Actor", "die", "Actor %s is now dead of %s", this, getDeathCause());
            if (!strand.isFiber())
                currentActor.set(null);
            JMXActorsMonitor.getInstance().actorTerminated(ref, strand);
        }
    }
View Full Code Here

    @Override
    public String toString() {
        String className = getClass().getSimpleName();
        if (className.isEmpty())
            className = getClass().getName().substring(getClass().getPackage().getName().length() + 1);
        final Strand strand = runner.getStrand();
        final String strandName = (strand != null ? strand.getName() : "null"); // strand.getClass().getSimpleName() + '@' + strand.getId()
        return className + "@"
                + (getName() != null ? getName() : Integer.toHexString(System.identityHashCode(this)))
                + "[owner: " + strandName + ']';
    }
View Full Code Here

        strand.join(timeout, unit);
    }

    @Override
    public final V get() throws InterruptedException, ExecutionException {
        final Strand s = strand;
        if (s == null)
            throw new IllegalStateException("Actor strand not set (not started?)");
        if (s instanceof Fiber)
            return ((Fiber<V>) s).get();
        else {
            s.join();
            return actor.getResult();
        }
    }
View Full Code Here

        if (old != null && actor.getMonitor() == null && isLocal(old) && LocalActor.getMonitor(old) != null)
            actor.setMonitor(LocalActor.getMonitor(old));
        if (actor.getMonitor() != null)
            actor.getMonitor().addRestart();

        final Strand strand;
        if (actor.getStrand() != null)
            strand = actor.getStrand();
        else
            strand = createStrandForActor(child.actor != null && isLocal(child.actor) ? LocalActor.getStrand(child.actor) : null, actor);

        try {
            strand.start();
        } catch (IllegalThreadStateException e) {
            log().info("Child {} has already been started.", actor);
        }

        return start(child, actor.ref());
View Full Code Here

TOP

Related Classes of co.paralleluniverse.strands.Strand

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.