All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.jctools.counters.FixedSizeStripedLongCounterV8 Maven / Gradle / Ivy

There is a newer version: 1.52.1
Show newest version
package org.jctools.counters;

import static org.jctools.util.UnsafeAccess.UNSAFE;

/**
 * Wait-free implementation of striped counter using
 * Java 8 Unsafe intrinsics (lock addq and lock xchg).
 *
 * @author Tolstopyatov Vsevolod
 */
class FixedSizeStripedLongCounterV8 extends FixedSizeStripedLongCounter {

    public FixedSizeStripedLongCounterV8(int stripesCount) {
        super(stripesCount);
    }

    @Override
    protected void inc(long[] cells, long offset, long delta) {
        UNSAFE.getAndAddLong(cells, offset, delta);
    }

    @Override
    protected long getAndReset(long[] cells, long offset) {
        return UNSAFE.getAndSetLong(cells, offset, 0L);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy