FileDocCategorySizeDatePackage
ConcurrentQueueImpl.javaAPI DocExample4891Tue May 29 16:57:04 BST 2007com.sun.xml.ws.transport.tcp.connectioncache.impl.concurrent

ConcurrentQueueImpl

public class ConcurrentQueueImpl extends Object implements com.sun.xml.ws.transport.tcp.connectioncache.spi.concurrent.ConcurrentQueue

Fields Summary
final Entry
head
int
count
Constructors Summary
public ConcurrentQueueImpl()


      
	head.next = head ;
	head.prev = head ;
    
Methods Summary
public Handleoffer(V arg)
Add a new element to the tail of the queue. Returns a handle for the element in the queue.

	if (arg == null)
	    throw new IllegalArgumentException( "Argument cannot be null" ) ;

	Entry<V> entry = new Entry<V>( arg ) ;
	
	entry.next = head ;
	entry.prev = head.prev ;
	head.prev.next = entry ;
	head.prev = entry ;
	count++ ;

	return entry.handle() ;
    
public Vpoll()
Return an element from the head of the queue. The element is removed from the queue.

	Entry<V> first = null ;
	V value = null ;

	first = head.next ;
	if (first == head)
	    return null ;
	else {
	    value = first.handle().value() ;

	    // assert that the following expression returns true!
	    first.handle().remove() ;
	}

	// Once first is removed from the queue, it is invisible to other threads,
	// so we don't need to synchronize here.
	first.next = null ;
	first.prev = null ;
	return value ;
    
public intsize()

	return count ;