Atomicity is a simple library to provide atomic operation to python's synchronization primitives for multi-threading
Project description
atomicity
Atomicity is a simple library that provides atomic operation to python's synchronization primitives used in multi-threading application.
*** Note: This is at a very early stage and is subject to changes. Use at your own risk. ***
It includes an atomic lock and counter class, ensuring (somewhat) thread-safety and prevention of race conditions in concurrent programming. Everything is entirely lock-free and is backed by Rust's atomic types.
Features
TBD
Installation
Binary wheels are provided for Python 3.8 and above on Linux, macOS, and Windows:
pip install atomicity
On Windows systems, The LLVM Compiler Infrastructure is required
Usage
See the documentation for more information. Here's a quick overview:
Atomic Counter
from atomicity import AtomicCounter
# Create an atomic integer with an initial value of 0
atom = AtomicCounter()
# Perform atomic operations
atom.set(10)
value = atom.get()
print(f"Value: {value}")
previous_value = atom.add( 20)
print(f"Previous Value: {previous_value}")
atom.sub(5)
print(f"Result after addition: {atom}")
# Increment and decrement operations
atom.increment()
atom.decrement()
Atomic Lock
from atomicity import AtomicLock
# Create an atomic boolean with an initial value of False
atom = AtomicLock( False)
# Perform atomic operations
atom.store(True)
value = atom.acquire()
previous_value = atom.release()
License
This project is licensed under the MIT License. See the LICENSE file for details.
Acknowledgments
- The
atomicity
library is heavily dependent on and inspired by the Ruststd::sync::atomic
module.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Hashes for atomicity-0.0.3-cp310-none-win_amd64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1ab89d8cd765b095de645124a72041e26ef1195dcf19404f72477d50d8b2ec4f |
|
MD5 | eeea1ea440af93fa5366b575e0c9793b |
|
BLAKE2b-256 | 0c19a0a1aadf3362eba58d6223882f2dff7f4184c2351668838d28a33dc0b6d8 |
Hashes for atomicity-0.0.3-cp310-cp310-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8a04ff9ff222ec34d72788f9beaf2e07a9041c69aa586477600867b2dcdc4f52 |
|
MD5 | 603f0d25128f004fde599d0c280662eb |
|
BLAKE2b-256 | 17aacb303ffed389f06c5e94a391e8e2f30273adabd430ec71aa97ef18412808 |
Hashes for atomicity-0.0.3-cp310-abi3-manylinux_2_34_x86_64.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 35562908e1c9820658fc7f9e1540f4d4f21a7e73786dae72012525d63afe32b7 |
|
MD5 | 88df874fb807fa544e880da4967334de |
|
BLAKE2b-256 | a01f06326c7ddd372ddf1e352db2d0ceeb83e8fb0bfe4ddf5ec038a100840bcf |