Package co.paralleluniverse.strands

Examples of co.paralleluniverse.strands.Condition


    }

    void attemptReceive() throws SuspendExecution, InterruptedException {
        if (isClosed())
            throw new EOFException();
        final Condition sync = channel.sync;
        sync.register();
        try {
            for (int i = 0; !consumer.hasNext(); i++) {
                if (channel.isSendClosed()) {
                    setReceiveClosed();
                    throw new EOFException();
                }
                sync.await(i);
            }
            consumer.poll0();
        } finally {
            sync.unregister();
        }
    }
View Full Code Here


    }

    void attemptReceive(long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException, TimeoutException {
        if (isClosed())
            throw new EOFException();
        final Condition sync = channel.sync;
        final long start = System.nanoTime();
        long left = unit.toNanos(timeout);
        sync.register();
        try {
            for (int i = 0; !consumer.hasNext(); i++) {
                if (channel.isSendClosed()) {
                    setReceiveClosed();
                    throw new EOFException();
                }
                sync.await(i, left, TimeUnit.NANOSECONDS);
                left = start + unit.toNanos(timeout) - System.nanoTime();
                if (left <= 0)
                    throw new TimeoutException();
            }
            consumer.poll0();
        } finally {
            sync.unregister();
        }
    }
View Full Code Here

    }

    void attemptReceive() throws SuspendExecution, InterruptedException {
        if (isClosed())
            throw new EOFException();
        final Condition sync = channel.sync;
        sync.register();
        try {
            for (int i = 0; !consumer.hasNext(); i++) {
                if (channel.isSendClosed()) {
                    setReceiveClosed();
                    throw new EOFException();
                }
                sync.await(i);
            }
            consumer.poll0();
        } finally {
            sync.unregister();
        }
    }
View Full Code Here

    }

    void attemptReceive(long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException, TimeoutException {
        if (isClosed())
            throw new EOFException();
        final Condition sync = channel.sync;
        long left = unit.toNanos(timeout);
        final long deadline = System.nanoTime() + left;
        sync.register();
        try {
            for (int i = 0; !consumer.hasNext(); i++) {
                if (channel.isSendClosed()) {
                    setReceiveClosed();
                    throw new EOFException();
                }
                sync.await(i, left, TimeUnit.NANOSECONDS);
                left = deadline - System.nanoTime();
                if (left <= 0)
                    throw new TimeoutException();
            }
            consumer.poll0();
        } finally {
            sync.unregister();
        }
    }
View Full Code Here

        return consumer.hasNext();
    }
   
    void attemptReceive() throws EOFException, SuspendExecution, InterruptedException {
        checkClosed();
        final Condition sync = channel.sync;
        Object token = sync.register();
        try {
            for (int i = 0; !consumer.hasNext(); i++) {
                if (channel.isSendClosed()) {
                    setReceiveClosed();
                    checkClosed();
                }
                sync.await(i);
            }
            consumer.poll0();
        } finally {
            sync.unregister(token);
        }
    }
View Full Code Here

        }
    }

    void attemptReceive(long timeout, TimeUnit unit) throws SuspendExecution, InterruptedException, TimeoutException, EOFException {
        checkClosed();
        final Condition sync = channel.sync;
        long left = unit.toNanos(timeout);
        final long deadline = System.nanoTime() + left;
        Object token = sync.register();
        try {
            for (int i = 0; !consumer.hasNext(); i++) {
                if (channel.isSendClosed()) {
                    setReceiveClosed();
                    checkClosed();
                }
                sync.await(i, left, TimeUnit.NANOSECONDS);
                left = deadline - System.nanoTime();
                if (left <= 0)
                    throw new TimeoutException();
            }
            consumer.poll0();
        } finally {
            sync.unregister(token);
        }
    }
View Full Code Here

    @Override
    public Object register(SelectAction<V> action) {
        if (action.isData())
            throw new UnsupportedOperationException("Send is not supported by DelayedValChanel");
        Condition sync = dv.getSync();
        if (sync == null) {
            if (!action.lease())
                return null;
            action.setItem(dv.getValue());
            action.won();
            return null;
        }
        sync.register();
        return action;
    }
View Full Code Here

    @Override
    public void unregister(Object token) {
        if (token == null)
            return;
        Condition sync = dv.getSync();
        if (sync != null)
            sync.unregister(null);
    }
View Full Code Here

TOP

Related Classes of co.paralleluniverse.strands.Condition

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.