Changeset 511 for Tests


Ignore:
Timestamp:
03/28/12 15:05:59 (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/AbstractSESDSequencer.java

    r510 r511  
    5050        } 
    5151        System.out.printf( 
    52                 "%s: useLazySet: %b, useUnsafe: %b, optimizeSpinWait: %b\n", 
     52                "%s: useLazySet: %b, optimizeSpinWait: %b, useUnsafe: %b\n", 
    5353                AbstractSESDSequencer.class.getSimpleName(), 
    5454                USE_LAZY_SET, 
    55                 USE_UNSAFE, 
    56                 OPTIMIZE_SPIN_WAIT 
     55                OPTIMIZE_SPIN_WAIT, 
     56                USE_UNSAFE 
    5757        ); 
    5858    } 
  • Tests/JAVA/test/src/main/java/test/threads/queue/unstressed/impl/CABSESDLazySetPaddedSpinOptimizedUnrolledQueue.java

    r510 r511  
    1414 * @since 27.09.11,  14:58 
    1515 */ 
    16 public class CABSESDLazySetPaddedQueueUnrolled<T> implements IQueue<T> { 
     16public class CABSESDLazySetPaddedSpinOptimizedUnrolledQueue<T> implements IQueue<T> { 
    1717    private static final boolean USE_BITMASK = true; 
    1818    //====================================================== 
    19     private static final AtomicLongFieldUpdater<CABSESDLazySetPaddedQueueUnrolled> tailUpdater = AtomicLongFieldUpdater.newUpdater( CABSESDLazySetPaddedQueueUnrolled.class, "tailCursor" ); 
    20     private static final AtomicLongFieldUpdater<CABSESDLazySetPaddedQueueUnrolled> headUpdater = AtomicLongFieldUpdater.newUpdater( CABSESDLazySetPaddedQueueUnrolled.class, "headCursor" ); 
     19    private static final AtomicLongFieldUpdater<CABSESDLazySetPaddedSpinOptimizedUnrolledQueue> tailUpdater = AtomicLongFieldUpdater.newUpdater( CABSESDLazySetPaddedSpinOptimizedUnrolledQueue.class, "tailCursor" ); 
     20    private static final AtomicLongFieldUpdater<CABSESDLazySetPaddedSpinOptimizedUnrolledQueue> headUpdater = AtomicLongFieldUpdater.newUpdater( CABSESDLazySetPaddedSpinOptimizedUnrolledQueue.class, "headCursor" ); 
    2121    //====================================================== 
    2222 
     
    4040    public volatile long p21, p22, p23, p24, p25, p26, p27, p28 = 8; 
    4141 
     42    private long lastHeadObserved = 0; 
     43    public volatile long p31, p32, p33, p34, p35, p36, p37, p38 = 9; 
     44    private long lastTailObserved = 0; 
     45 
     46 
    4247    public long sumPaddingToPreventOptimisation() { 
    4348        return p11 + p12 + p13 + p14 + p15 + p16 + p17 + p18 
    44                 + p21 + p22 + p23 + p24 + p25 + p26 + p27 + p28; 
     49                + p21 + p22 + p23 + p24 + p25 + p26 + p27 + p28 
     50                + p31 + p32 + p33 + p34 + p35 + p36 + p37 + p38; 
    4551    } 
    4652 
     
    4854 
    4955 
    50     public CABSESDLazySetPaddedQueueUnrolled( final int length ) { 
     56    public CABSESDLazySetPaddedSpinOptimizedUnrolledQueue( final int length ) { 
    5157        checkArgument( length > 0, "length(%s) must be >0", length ); 
    5258        if ( USE_BITMASK ) { 
     
    8894        //spin-wait: "while not full" 
    8995        final long target = tail - length; 
    90         while ( target == headCursor ) { 
    91 //            Thread.yield(); 
     96        while ( target == lastHeadObserved ) { 
     97            lastHeadObserved = headCursor; 
    9298        } 
    9399    } 
     
    95101    private void waitWhileNotEmpty( final long head ) { 
    96102        //spin-wait: "while not empty" 
    97         while ( head == tailCursor ) { 
    98 //            Thread.yield(); 
     103        while ( head == lastTailObserved ) { 
     104            lastTailObserved = tailCursor; 
    99105        } 
    100106    } 
     
    133139 
    134140    @SuppressWarnings( "unchecked" ) 
    135     public static <T> IBoundedQueueFactory<T, CABSESDLazySetPaddedQueueUnrolled<T>> factory() { 
     141    public static <T> IBoundedQueueFactory<T, CABSESDLazySetPaddedSpinOptimizedUnrolledQueue<T>> factory() { 
    136142        return FACTORY; 
    137143    } 
    138144 
    139     public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CABSESDLazySetPaddedQueueUnrolled<Object>>() { 
     145    public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CABSESDLazySetPaddedSpinOptimizedUnrolledQueue<Object>>() { 
    140146        @Override 
    141         public CABSESDLazySetPaddedQueueUnrolled<Object> create( final int size ) { 
    142             return new CABSESDLazySetPaddedQueueUnrolled<Object>( size ); 
     147        public CABSESDLazySetPaddedSpinOptimizedUnrolledQueue<Object> create( final int size ) { 
     148            return new CABSESDLazySetPaddedSpinOptimizedUnrolledQueue<Object>( size ); 
    143149        } 
    144150 
    145151        @Override 
    146152        public String toString() { 
    147             return "SESDLazySetPaddedQueueUnrolledFactory[" + ( USE_BITMASK ? "&" : "%" ) + "]"; 
     153            return "LazySetPaddedSpinOptimizedUnrolledQueueFactory[" + ( USE_BITMASK ? "&" : "%" ) + "]"; 
    148154        } 
    149155    }; 
Note: See TracChangeset for help on using the changeset viewer.