Skip to content

Add AtomicIntCounter #58

Description

@dpdani
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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions