Java 8 LongAdder - 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 LongAdder class.

This code example shows how to use the following methods:
/** 
 * 
 * @author pron 
 */ 
public class Counter { 
    private final LongAdder la = new LongAdder();
    // private final AtomicLong al = new AtomicLong(); 
 
    public void reset() { 
        la.reset();
        //al.set(0); 
    } 
 
    public void inc() { 
        la.increment();
        //al.incrementAndGet(); 
    } 
 
    public void dec() { 
        la.decrement();
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:
    /** 
     * Default constructor 
     */ 
    public LongAdderRWLock() {	      		 
        readersIngress = new LongAdder();
        readersEgress = new LongAdder();
        stampedLock = new StampedLock();        
        readerLock = new LongAdderRWLock.InnerReadLock();
        writerLock = new LongAdderRWLock.InnerWriteLock();
    } 
     
    public Lock readLock() { return readerLock; }
    public Lock writeLock() { return writerLock; }    
     
 
    /** 
     * Acquires the read lock. 
     * 
     * <p>Acquires the read lock if the write lock is not held by 
     * another thread and returns immediately. 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
        private final LongAdder liveThreads;
         
        private final AtomicLong maxLiveThreads;
         
        public DiffSummaryStatistics(){ 
            count = new LongAdder();
 
            vsz = new LongAdder();
            maxVSZ = new AtomicLong();
             
            rss = new LongAdder();
            maxRSS = new AtomicLong();
             
            liveThreads = new LongAdder();
            maxLiveThreads = new AtomicLong();
        } 
         
        public void accept(LogData logData){
            count.increment();
             
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
 
    private LongAdder inUseCount = new LongAdder();
    private LongAdder idleCount = new LongAdder();
    private LongAdder totalConnections = new LongAdder();
    private LongAdder pendingAcquire = new LongAdder();
    private LongAdder pendingRelease = new LongAdder();
 
    @Override 
    protected void onPoolReleaseFailed(long duration, TimeUnit timeUnit, Throwable throwable) {
        pendingRelease.decrement();
    } 
 
    @Override 
    protected void onPoolReleaseSuccess(long duration, TimeUnit timeUnit) {
        pendingRelease.decrement();
        idleCount.increment();
        inUseCount.decrement();
    } 
 
    @Override 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
/** 
 * @author Nitesh Kant 
 */ 
public class ConnectionPoolMetricListener extends HttpClientMetricEventsListener { 
 
    private LongAdder inUseCount = new LongAdder();
    private LongAdder idleCount = new LongAdder();
    private LongAdder totalConnections = new LongAdder();
    private LongAdder pendingAcquire = new LongAdder();
    private LongAdder pendingRelease = new LongAdder();
 
    @Override 
    protected void onPoolReleaseFailed(long duration, TimeUnit timeUnit, Throwable throwable) {
        pendingRelease.decrement();
    } 
 
    @Override 
    protected void onPoolReleaseSuccess(long duration, TimeUnit timeUnit) {
        pendingRelease.decrement();
        idleCount.increment();
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
This code example shows how to use the following methods:
    // Tests that simple task scheduling and execution works. 
    @Test public void schedule() throws Exception { 
        final int THREAD_COUNT = 4, MEMORY_SIZE = 1024, TASK_COUNT = 100; 
        final BoundedThreadPool pool = new BoundedThreadPool(THREAD_COUNT, MEMORY_SIZE); 
 
        final LongAdder counter = new LongAdder(); 
        for (int i = 0; i < TASK_COUNT; i++) { 
            Assert.assertTrue(pool.schedule(counter::increment, 0)); 
        } 
        pool.terminate(false); 
        Assert.assertEquals(TASK_COUNT, counter.intValue()); 
    } 
 
    // Tests that memory bounds are complied with. 
    @Test public void capacity() throws Exception { 
        final int THREAD_COUNT = 1, MEMORY_SIZE = 1; 
        final BoundedThreadPool pool = new BoundedThreadPool(THREAD_COUNT, MEMORY_SIZE); 
 
        Assert.assertTrue(pool.schedule(() -> {}, 1)); 
        Assert.assertFalse(pool.schedule(() -> {}, 2)); 
3
CodeRank
Connect your IDE to all the code out there  Get Codota for Java
See Code Examples for Java 8 LongAdder Methods: