org.tranche.httpd
Class Queue

java.lang.Object
  extended by org.tranche.httpd.Queue

public class Queue
extends java.lang.Object

This class defines the Queue in which sockets are placed temporarily by httpd. AbstractHttpHandlers look here for the next socket to handle. These handlers are cratead and their threads started up during construction of the class and placed in a threadPool.

Author:
TPapoulias

Constructor Summary
Queue(int maxQLength, int minNumThreads, int maxNumThreads)
          Constructor
 
Method Summary
 void add(java.net.Socket socket)
          The proper way of adding sockets to the queue.
 java.net.Socket getNextSocket()
          Method used for retrieving next item in the queue.
 void shutdown()
          Methods for shutting down the queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Queue

public Queue(int maxQLength,
             int minNumThreads,
             int maxNumThreads)
Constructor

Parameters:
maxQLength - The size of the queue
minNumThreads - The minimum number of SocketHandler threads active.
maxNumThreads - The maximum number of SocketHandler threads.
Method Detail

add

public void add(java.net.Socket socket)
         throws QueueException
The proper way of adding sockets to the queue. If the size of the queue is exited the socket is not added and an QueueException thrown. Once the socket is added to the bottom of the queue the method adds more SocketHandler threads.

Parameters:
socket - The socket to be added to the queue.
Throws:
QueueException

getNextSocket

public java.net.Socket getNextSocket()
Method used for retrieving next item in the queue.

Returns:
The next socket in the queue awaiting service

shutdown

public void shutdown()
Methods for shutting down the queue. It first sets the isRunning flag to false. Calls the killThread() method of every thread in the threadpool.



This code is free for use both commercially and non-commercially as stated in the project's license