Package org.agilewiki.jactor.lpc.timingTest

Source Code of org.agilewiki.jactor.lpc.timingTest.Sender1

package org.agilewiki.jactor.lpc.timingTest;

import org.agilewiki.jactor.*;
import org.agilewiki.jactor.lpc.JLPCActor;
import org.agilewiki.jactor.Actor;
import org.agilewiki.jactor.JAIterator;
import org.agilewiki.jactor.RP;

/**
* Test code.
*/
public class Sender1 extends JLPCActor implements SimpleRequestReceiver, RealRequestReceiver {

    private Actor echo;
    private final int count;

    public Sender1(Actor echo, int c, int b) {
        this.echo = echo;
        echo.setInitialBufferCapacity(b + 10);
        count = c;
    }

    @Override
    public void processRequest(final SimpleRequest unwrappedRequest, final RP rd1)
            throws Exception {
        (new JAIterator() {
            int i;

            @Override
            public void process(final RP rd2) throws Exception {
                if (i > count) rd2.processResponse(this);
                else {
                    i += 1;
                    rd2.processResponse(null);
                }
            }
        }).iterate(rd1);
    }

    @Override
    public void processRequest(final RealRequest unwrappedRequest, final RP rd1)
            throws Exception {
        (new JAIterator() {
            int i;

            @Override
            public void process(final RP rd2) throws Exception {
                if (i > count) rd2.processResponse(this);
                else {
                    i += 1;
                    SimpleRequest.req.send(Sender1.this, echo, rd2);
                }
            }
        }).iterate(rd1);
    }
}
TOP

Related Classes of org.agilewiki.jactor.lpc.timingTest.Sender1

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.