Java 8 AtomicStampedReference - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 AtomicStampedReference class.

This code example shows how to use the following methods:compareAndSet, getReference
 
        int stamp=(int)(next / capacity);
 
        int index=(int)(next % capacity);
        AtomicStampedReference<T> ref=queue[index];
        T retval=ref.getReference();
 
 
        if(retval != null && ref.compareAndSet(retval, null, stamp, -1)) {
            // operations.add("queue[" + index + "]: " + retval + " = null (next=" + next + ")"); 
            // successful_removes.incrementAndGet(); 
            next_to_remove.incrementAndGet();
            return retval;
        } 
//        else 
//            failed_removes.incrementAndGet(); 
 
        return null; 
    } 
 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:compareAndSet, get
    private OnlyFirstRequest retrieveFirstRequestObserver() { 
 
        int key = warpContext().hashCode();
 
        int[] stampHolder = new int[1];
        OnlyFirstRequest onlyFirstRequest = firstRequestObserver.get(stampHolder);
 
        if (key != stampHolder[0]) {
            firstRequestObserver.compareAndSet(onlyFirstRequest, new OnlyFirstRequest(), stampHolder[0], key);
        } 
 
        onlyFirstRequest = firstRequestObserver.get(stampHolder);
 
        if (stampHolder[0] != key) {
            warpContext().pushException(new IllegalStateException("There should be only one concurrent Warp execution"));
        } 
 
        return onlyFirstRequest;
    } 
} 
5
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 AtomicStampedReference Methods: