Changeset 507 for Tests


Ignore:
Timestamp:
03/27/12 21:07:42 (10 years ago)
Author:
BegemoT
Message:
 
File:
1 copied

Legend:

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

    r502 r507  
    11package test.threads.queue.unstressed.impl; 
     2 
     3import java.util.concurrent.atomic.AtomicLongFieldUpdater; 
    24 
    35import test.threads.queue.unstressed.IBoundedQueueFactory; 
     
    1214 * @since 27.09.11,  14:58 
    1315 */ 
    14 public class CABSESDQueueUnrolled<T> implements IQueue<T> { 
     16public class CABSESDLazySetQueueUnrolled<T> implements IQueue<T> { 
    1517    private static final boolean USE_BITMASK = true; 
     18    //====================================================== 
     19    private static final AtomicLongFieldUpdater<CABSESDLazySetQueueUnrolled> tailUpdater = AtomicLongFieldUpdater.newUpdater( CABSESDLazySetQueueUnrolled.class, "tailCursor" ); 
     20    private static final AtomicLongFieldUpdater<CABSESDLazySetQueueUnrolled> headUpdater = AtomicLongFieldUpdater.newUpdater( CABSESDLazySetQueueUnrolled.class, "headCursor" ); 
     21    //====================================================== 
     22 
    1623    /* Elements range: [headCursor, tailCursor) 
    1724    * 
     
    4249 
    4350 
    44     public CABSESDQueueUnrolled( final int length ) { 
     51    public CABSESDLazySetQueueUnrolled( final int length ) { 
    4552        checkArgument( length > 0, "length(%s) must be >0", length ); 
    4653        if ( USE_BITMASK ) { 
     
    7077    private void publishTail( final long newTail ) { 
    7178        assert ( newTail >= headCursor ) : "newTail(" + newTail + ") < headCursor(" + headCursor + ")"; 
    72         tailCursor = newTail; 
     79        tailUpdater.lazySet( this, newTail ); 
    7380    } 
    7481 
    7582    private void publishHead( final long newHead ) { 
    7683        assert ( newHead <= tailCursor ) : "newHead(" + newHead + ") > tailCursor(" + tailCursor + ")"; 
    77         headCursor = newHead; 
     84        headUpdater.lazySet( this, newHead ); 
    7885    } 
    7986 
     
    127134 
    128135    @SuppressWarnings( "unchecked" ) 
    129     public static <T> IBoundedQueueFactory<T, CABSESDQueueUnrolled<T>> factory() { 
     136    public static <T> IBoundedQueueFactory<T, CABSESDLazySetQueueUnrolled<T>> factory() { 
    130137        return FACTORY; 
    131138    } 
    132139 
    133     public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CABSESDQueueUnrolled<Object>>() { 
     140    public static final IBoundedQueueFactory FACTORY = new IBoundedQueueFactory<Object, CABSESDLazySetQueueUnrolled<Object>>() { 
    134141        @Override 
    135         public CABSESDQueueUnrolled<Object> create( final int size ) { 
    136             return new CABSESDQueueUnrolled<Object>( size ); 
     142        public CABSESDLazySetQueueUnrolled<Object> create( final int size ) { 
     143            return new CABSESDLazySetQueueUnrolled<Object>( size ); 
    137144        } 
    138145 
Note: See TracChangeset for help on using the changeset viewer.