- Timestamp:
- 04/01/12 17:17:31 (10 years ago)
- File:
-
- 1 copied
Legend:
- Unmodified
- Added
- Removed
-
Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl/DummyQueue.java
r524 r526 1 1 package test.threads.queue.unstressed.impl; 2 2 3 import java.util.concurrent.ArrayBlockingQueue; 4 3 import test.threads.queue.stressed.cpu.LongValueMessage; 5 4 import test.threads.queue.unstressed.IBoundedQueueFactory; 6 5 import test.threads.queue.unstressed.IQueue; 7 6 8 7 /** 9 * Самый базовый вариант, адаптер ABQ к интерфейсу IQueue. 8 * Фальшивая реализация -- для измерения погрешностей, вносимых в измерения 9 * нашей инфраструктурой 10 10 * 11 11 * @author cheremin 12 12 * @since 22.09.11, 13:09 13 13 */ 14 public class ABQWrapperQueue<T> implements IQueue<T> {14 public class DummyQueue<T> implements IQueue<T> { 15 15 16 private final ArrayBlockingQueue<T> queue;16 private final LongValueMessage message = new LongValueMessage( 42 ); 17 17 18 public ABQWrapperQueue( final int size ) { 19 this.queue = new ArrayBlockingQueue<T>( size ); 18 public DummyQueue( final int size ) { 20 19 } 21 20 22 21 @Override 23 22 public void enqueue( final T item ) throws InterruptedException { 24 queue.put( item );25 23 } 26 24 27 25 @Override 28 26 public T dequeue() throws InterruptedException { 29 return queue.take();27 return ( T ) message; 30 28 } 31 29 32 30 @Override 33 31 public int size() { 34 return queue.size();32 return 0; 35 33 } 36 34 37 35 @SuppressWarnings( "unchecked" ) 38 public static <T> IBoundedQueueFactory<T, ABQWrapperQueue<T>> factory() {36 public static <T> IBoundedQueueFactory<T, DummyQueue<T>> factory() { 39 37 return FACTORY; 40 38 } 41 39 42 public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, ABQWrapperQueue<Object>>() {40 public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, DummyQueue<Object>>() { 43 41 @Override 44 public ABQWrapperQueue<Object> create( final int size ) {45 return new ABQWrapperQueue<Object>( size );42 public DummyQueue<Object> create( final int size ) { 43 return new DummyQueue<Object>( size ); 46 44 } 47 45 48 46 @Override 49 47 public String toString() { 50 return " ABQWrapperFactory";48 return "DummyFactory"; 51 49 } 52 50 };
Note: See TracChangeset
for help on using the changeset viewer.