from cereggii import AtomicIntCounter
c = AtomicIntCounter(0)
c.increment(10)
c.increment() # by 1
c.decrement()
c.get() # blocks concurrent accessors
The difference between this AtomicIntCounter and AtomicInt64 or AtomicNumber is that this is optimized for reducing contention during writes, while it creates contention around reads.
When calling AtomicIntCounter.increment(), no shared variable should be touched. Instead, a thread-local shard of the count should be updated.
This is best implemented with thread local storage in C.
Differently from AtomicInt64, there should be no AtomicIntCounter.increment_and_get() because we would like to discourage frequent reads.
The difference between this
AtomicIntCounterandAtomicInt64orAtomicNumberis that this is optimized for reducing contention during writes, while it creates contention around reads.When calling
AtomicIntCounter.increment(), no shared variable should be touched. Instead, a thread-local shard of the count should be updated.This is best implemented with thread local storage in C.
Differently from
AtomicInt64, there should be noAtomicIntCounter.increment_and_get()because we would like to discourage frequent reads.