Changeset 525 for Tests


Ignore:
Timestamp:
03/31/12 15:46:52 (10 years ago)
Author:
BegemoT
Message:
 
Location:
Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl
Files:
1 edited
1 copied

Legend:

Unmodified
Added
Removed
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl/CLQWrapperQueue.java

    r524 r525  
    11package test.threads.queue.unstressed.impl; 
    22 
    3 import java.util.concurrent.ArrayBlockingQueue; 
    4 import java.util.concurrent.LinkedBlockingQueue; 
     3import java.util.concurrent.ConcurrentLinkedQueue; 
    54 
    65import test.threads.queue.unstressed.IBoundedQueueFactory; 
     
    87 
    98/** 
    10  * Самый базовый вариант, адаптер {@link LinkedBlockingQueue} к интерфейсу IQueue. 
     9 * Самый базовый вариант, адаптер {@link java.util.concurrent.ConcurrentLinkedQueue} к интерфейсу IQueue. 
    1110 * 
    1211 * @author cheremin 
    1312 * @since 22.09.11,  13:09 
    1413 */ 
    15 public class LBQWrapperQueue<T> implements IQueue<T> { 
     14public class CLQWrapperQueue<T> implements IQueue<T> { 
    1615 
    17     private final LinkedBlockingQueue<T> queue; 
     16    private final ConcurrentLinkedQueue<T> queue; 
     17    private final int size; 
    1818 
    19     public LBQWrapperQueue( final int size ) { 
    20         this.queue = new LinkedBlockingQueue<T>( size ); 
     19    public CLQWrapperQueue( final int size ) { 
     20        this.queue = new ConcurrentLinkedQueue<T>(); 
     21        this.size = size; 
    2122    } 
    2223 
    2324    @Override 
    2425    public void enqueue( final T item ) throws InterruptedException { 
    25         queue.put( item ); 
     26        while ( queue.size() >= size ) { 
     27        } 
     28        queue.add( item ); 
    2629    } 
    2730 
    2831    @Override 
    2932    public T dequeue() throws InterruptedException { 
    30         return queue.take(); 
     33        while ( true ) { 
     34            final T event = queue.poll(); 
     35            if ( event != null ) { 
     36                return event; 
     37            } 
     38        } 
    3139    } 
    3240 
     
    3745 
    3846    @SuppressWarnings( "unchecked" ) 
    39     public static <T> IBoundedQueueFactory<T, LBQWrapperQueue<T>> factory() { 
     47    public static <T> IBoundedQueueFactory<T, CLQWrapperQueue<T>> factory() { 
    4048        return FACTORY; 
    4149    } 
    4250 
    43     public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, LBQWrapperQueue<Object>>() { 
     51    public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CLQWrapperQueue<Object>>() { 
    4452        @Override 
    45         public LBQWrapperQueue<Object> create( final int size ) { 
    46             return new LBQWrapperQueue<Object>( size ); 
     53        public CLQWrapperQueue<Object> create( final int size ) { 
     54            return new CLQWrapperQueue<Object>( size ); 
    4755        } 
    4856 
    4957        @Override 
    5058        public String toString() { 
    51             return "ABQWrapperFactory"; 
     59            return "CLQWrapperFactory"; 
    5260        } 
    5361    }; 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl/LBQWrapperQueue.java

    r524 r525  
    4949        @Override 
    5050        public String toString() { 
    51             return "ABQWrapperFactory"; 
     51            return "LBQWrapperFactory"; 
    5252        } 
    5353    }; 
Note: See TracChangeset for help on using the changeset viewer.