atomiclong

A CFFI using AtomicLong type for CPython and PyPy.

AtomicLong

Sometimes you need to increment some numbers … atomically … in python.

AtomicLong was born out of the need for fast thread-safe counters in python.

It uses CFFI_ to bind GCC's Atomic Builtins_.

Its value is a C long which can be incremented, decremented, and set atomically. It is inspired by Java’s java.util.concurrent.atomic.AtomicLong_.

Example::

>>> from atomiclong import AtomicLong
>>> a = AtomicLong(0)
>>> a += 1
>>> a.value
1
>>> a += 10
>>> a.value
11
>>> a.value = 1000
>>> a.value
1000
>>> a -= 100
>>> a.value
900

.. _GCC’s Atomic Builtins: http://gcc.gnu.org/onlinedocs/gcc-4.3.5/gcc/Atomic-Builtins.html

.. _CFFI: https://cffi.readthedocs.org

.. _java.util.concurrent.atomic.AtomicLong: http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/atomic/AtomicLong.html

Related Repositories

redisson

redisson

Redisson - distributed Java objects and services (Set, Multimap, SortedSet, Map, List, Queue, BlockingQueue, Deque, BlockingDeque, Semaphore, Lock, AtomicLong, CountDownLatch, Publish / Subscribe, Bloom filter, Spring Cache, Executor service, Tomcat Sessi ...

redisson

redisson

Redisson - distributed Java objects and services (Set, Multimap, SortedSet, Map, List, Queue, BlockingQueue, Deque, BlockingDeque, Semaphore, Lock, AtomicLong, CountDownLatch, Publish / Subscribe, Bloom filter, Spring Cache, Executor service, Tomcat Sessi ...

atomiclong

atomiclong

A CFFI using AtomicLong type for CPython and PyPy. ...

atomiclong

atomiclong

A CFFI using AtomicLong type for CPython and PyPy. ...


Top Contributors

dreid alex