java.util.concurrent.atomic.AtomicLongFieldUpdater

Here are the examples of the java api class java.util.concurrent.atomic.AtomicLongFieldUpdater taken from open source projects.

1. Atomic8Test#testLongFieldUpdaterGetAndUpdate()

Project: openjdk
Source File: Atomic8Test.java
View license
/**
     * AtomicLongFieldUpdater getAndUpdate returns previous value and updates
     * result of supplied function
     */
public void testLongFieldUpdaterGetAndUpdate() {
    AtomicLongFieldUpdater a = aLongFieldUpdater();
    a.set(this, 1);
    assertEquals(1L, a.getAndUpdate(this, Atomic8Test::addLong17));
    assertEquals(18L, a.getAndUpdate(this, Atomic8Test::addLong17));
    assertEquals(35L, a.get(this));
    assertEquals(35L, aLongField);
}

2. Atomic8Test#testLongFieldUpdaterUpdateAndGet()

Project: openjdk
Source File: Atomic8Test.java
View license
/**
     * AtomicLongFieldUpdater updateAndGet updates with supplied function and
     * returns result.
     */
public void testLongFieldUpdaterUpdateAndGet() {
    AtomicLongFieldUpdater a = aLongFieldUpdater();
    a.set(this, 1);
    assertEquals(18L, a.updateAndGet(this, Atomic8Test::addLong17));
    assertEquals(35L, a.updateAndGet(this, Atomic8Test::addLong17));
    assertEquals(35L, a.get(this));
    assertEquals(35L, aLongField);
}

3. Atomic8Test#testLongFieldUpdaterGetAndAccumulate()

Project: openjdk
Source File: Atomic8Test.java
View license
/**
     * AtomicLongFieldUpdater getAndAccumulate returns previous value
     * and updates with supplied function.
     */
public void testLongFieldUpdaterGetAndAccumulate() {
    AtomicLongFieldUpdater a = aLongFieldUpdater();
    a.set(this, 1);
    assertEquals(1L, a.getAndAccumulate(this, 2L, Long::sum));
    assertEquals(3L, a.getAndAccumulate(this, 3L, Long::sum));
    assertEquals(6L, a.get(this));
    assertEquals(6L, aLongField);
}

4. Atomic8Test#testLongFieldUpdaterAccumulateAndGet()

Project: openjdk
Source File: Atomic8Test.java
View license
/**
     * AtomicLongFieldUpdater accumulateAndGet updates with supplied
     * function and returns result.
     */
public void testLongFieldUpdaterAccumulateAndGet() {
    AtomicLongFieldUpdater a = aLongFieldUpdater();
    a.set(this, 1);
    assertEquals(7L, a.accumulateAndGet(this, 6L, Long::sum));
    assertEquals(10L, a.accumulateAndGet(this, 3L, Long::sum));
    assertEquals(10L, a.get(this));
    assertEquals(10L, aLongField);
}