Package groovyx.gpars.actor

Examples of groovyx.gpars.actor.ActorMessage


    @SuppressWarnings({"AssignmentToMethodParameter"})
    @Override
    public MessageStream send(Object message) {
        if (!(message instanceof ActorMessage)) {
            message = new ActorMessage(message, Actor.threadBoundActor());
        }
        remoteHost.write(new MessageStream.SendTo(this, (ActorMessage) message));
        return this;
    }
View Full Code Here


    protected final ActorMessage pollMessage() {
        assert isActorThread();

        transferQueues();

        ActorMessage toProcess = null;
        if (outputQueue != null) {
            toProcess = outputQueue.msg;
            outputQueue = outputQueue.next;
        }
        return toProcess;
View Full Code Here

     */
    protected final ActorMessage takeMessage() throws InterruptedException {
        assert isActorThread();

        while (true) {
            final ActorMessage message = awaitNextMessage(0L);
            if (message != null) return message;
        }
    }
View Full Code Here

    protected ActorMessage takeMessage(final long timeout, final TimeUnit timeUnit) throws InterruptedException {
        assert isActorThread();

        final long endTime = System.nanoTime() + timeUnit.toNanos(timeout);
        do {
            final ActorMessage message = awaitNextMessage(endTime);
            if (message != null) return message;
        } while (System.nanoTime() < endTime);

        handleTimeout();
        return TIMEOUT_MESSAGE;
View Full Code Here

     * Takes the next message from the outputQueue, decrements the counter and possibly throws control exceptions
     *
     * @return The next message
     */
    private ActorMessage retrieveNextMessage() {
        final ActorMessage toProcess = outputQueue.msg;
        outputQueue = outputQueue.next;

        throwIfNeeded(toProcess);
        return toProcess;
    }
View Full Code Here

            try {
                if (stopFlag == S_TERMINATING) {
                    throw TERMINATE;
                }
                final ActorMessage toProcess = takeMessage();

                if (toProcess == START_MESSAGE) {
                    handleStart();

                    // if we came here it means no loop was started
View Full Code Here

     * @param replyTo where to send reply
     * @param <T>     type of message accepted by the stream
     * @return always return message stream itself
     */
    public final <T> MessageStream send(final T message, final MessageStream replyTo) {
        return send(new ActorMessage(message, replyTo));
    }
View Full Code Here

     * @return The message that came in reply to the original send.
     * @throws InterruptedException if interrupted while waiting
     */
    public final <T, V> V sendAndWait(final T message) throws InterruptedException {
        final ResultWaiter<V> to = new ResultWaiter<V>();
        send(new ActorMessage(message, to));
        return to.getResult();
    }
View Full Code Here

     * @return The message that came in reply to the original send.
     * @throws InterruptedException if interrupted while waiting
     */
    public final <T> Object sendAndWait(final T message, final long timeout, final TimeUnit units) throws InterruptedException {
        final ResultWaiter<Object> to = new ResultWaiter<Object>();
        send(new ActorMessage(message, to));
        return to.getResult(timeout, units);
    }
View Full Code Here

        @SuppressWarnings({"AssignmentToMethodParameter"})
        @Override
        public MessageStream send(Object message) {
            if (!(message instanceof ActorMessage)) {
                message = new ActorMessage(message, Actor.threadBoundActor());
            }
            remoteHost.write(new SendTo(this, (ActorMessage) message));
            return this;
        }
View Full Code Here

TOP

Related Classes of groovyx.gpars.actor.ActorMessage

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.