view src/org/dancres/blitz/remote/nio/ResultReceiver.java @ 34:6f68e94c1fb8 default tip

Add CondensedStats monitoring utility, equivalent to vmstat
author Dominic Cleal <dominic-cleal@cdo2.com>
date Thu, 05 Aug 2010 11:07:25 +0100
parents 3dc0c5604566
children
line wrap: on
line source

package org.dancres.blitz.remote.nio;

import java.rmi.RemoteException;

/**
 */
public class ResultReceiver implements ResultProcessor {
    private byte[] _payload;
    private RemoteException _throwable;

    public synchronized void deliver(byte[] aPayload) {
        // System.err.println("Deliver");
        _payload = aPayload;
        notify();
    }

    public synchronized void deliver(RemoteException aT) {
        _throwable = aT;
        notify();
    }

    synchronized byte[] getPayload() throws RemoteException {
        while ((_payload == null) && (_throwable == null)) {
            try {
                wait();
            } catch (InterruptedException anIE) {
            }
        }

        if (_throwable != null)
                throw _throwable;

        // System.err.println("Got payload: " + _payload.length);
        return _payload;
    }
}