org.sapia.ubik.net.mplex
Class SocketQueue

java.lang.Object
  extended by org.sapia.ubik.net.mplex.SocketQueue

public class SocketQueue
extends java.lang.Object

This class implements a simple asynchronous, thread safe, FIFO queue of Socket objects. A producer actor can add a new socket to the queue by calling the add(Socket) method. A consumer actor can retrieve the next available socket from the queue using the getSocket() method.

Upon creation a SocketQueue is considered active or open; therefore producers and consumers can use the queue. When the queue is no longer necessary the close() method will put the queue in a closed state where:

Author:
Jean-Cedric Desrochers
Copyright:
Copyright © 2002-2004 Sapia Open Source Software. All Rights Reserved.
License:
Read the license.txt file of the jar or visit the license page at the Sapia OSS web site

Constructor Summary
SocketQueue()
          Creates a new SocketQueue instance.
 
Method Summary
 void add(java.net.Socket aSocket)
          Asynchronously add the socket passed in to the internal queue.
 void close()
          Close this queue.
 java.io.IOException getException()
          Returns the current exception of this queue.
 java.net.Socket getSocket()
          Returns the next available socket.
 void setException(java.io.IOException anException)
          Sets the exception to this queue.
 int size()
          Returns the number of socket pending in the internal queue.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SocketQueue

public SocketQueue()
Creates a new SocketQueue instance.

Method Detail

add

public void add(java.net.Socket aSocket)
         throws java.net.SocketException
Asynchronously add the socket passed in to the internal queue.

Parameters:
aSocket - The socket to add.
Throws:
java.net.SocketException

getSocket

public java.net.Socket getSocket()
                          throws java.io.IOException
Returns the next available socket. This method will block until a socket is available.

Returns:
The next available socket.
Throws:
java.io.IOException

close

public void close()
Close this queue.


setException

public void setException(java.io.IOException anException)
Sets the exception to this queue.

Parameters:
anException - The exception to send to the client.

getException

public java.io.IOException getException()
Returns the current exception of this queue.

Returns:
The current exception of this queue.

size

public int size()
Returns the number of socket pending in the internal queue.

Returns:
The number of socket pending in the internal queue.


Copyright © 2010 Sapia OSS. All Rights Reserved.