FileDocCategorySizeDatePackage
LeaderFollowerWorkerThread.javaAPI DocApache Tomcat 6.0.143022Fri Jul 20 04:20:36 BST 2007org.apache.tomcat.util.net

LeaderFollowerWorkerThread

public class LeaderFollowerWorkerThread extends Object implements org.apache.tomcat.util.threads.ThreadPoolRunnable

Fields Summary
PoolTcpEndpoint
endpoint
Constructors Summary
public LeaderFollowerWorkerThread(PoolTcpEndpoint endpoint)

        this.endpoint = endpoint;
    
Methods Summary
public java.lang.Object[]getInitData()

        // no synchronization overhead, but 2 array access 
        Object obj[]=new Object[2];
        obj[1]= endpoint.getConnectionHandler().init();
        obj[0]=new TcpConnection();
        return obj;
    
public voidrunIt(java.lang.Object[] perThrData)


        // Create per-thread cache
        if (endpoint.isRunning()) {

            // Loop if endpoint is paused
            while (endpoint.isPaused()) {
                try {
                    Thread.sleep(1000);
                } catch (InterruptedException e) {
                    // Ignore
                }
            }

            // Accept a new connection
            Socket s = null;
            try {
                s = endpoint.acceptSocket();
            } finally {
                // Continue accepting on another thread...
                if (endpoint.isRunning()) {
                    endpoint.tp.runIt(this);
                }
            }

            // Process the connection
            if (null != s) {
                endpoint.processSocket(s, (TcpConnection) perThrData[0], (Object[]) perThrData[1]);
            }

        }