Skip to content

v2.0

Choose a tag to compare

@TahsinCr TahsinCr released this 02 Mar 14:22
· 6 commits to main since this release

[2.0] - 02.03.2026

Add highly optimized O(1) RWCondition and AsyncRWCondition primitives with flawless cancellation shielding. Also rename all *SafeWriter classes to *ReentrantWriter and expand test coverage for the v2.0 release.

Added

  • Condition Variables for Thread & Async Environments:
    • Introduced RWCondition (Thread) and AsyncRWCondition (Asyncio) primitives.
    • Condition variables can now wrap any specific scheduling strategy (Write-Pref, Read-Pref, FIFO, and Reentrant variants) via Dependency Injection.
    • Standard Condition's O(N) wake-up traversal has been completely bypassed.
    • RWCondition utilizes a deque with micro-locks, and AsyncRWCondition utilizes a native deque of asyncio.Future objects to provide pure O(1) time complexity for wait(), notify(), and notify_all() operations.
  • Condition Smart Proxies & Downgrade Safety:
    • Implemented .read and .write proxies for Condition objects (RWConditionProxy, AsyncRWConditionProxy).
    • The Smart Proxy intelligently routes the release operations back to the correct state even if an Atomic Downgrade was performed while holding a lock inside a condition block.
  • Flawless Cancellation Shielding (Asyncio):
    • Re-engineered the AsyncRWConditionProxy.wait() method to be absolutely resilient to asyncio.CancelledError. Tasks that are cancelled while sleeping now securely re-acquire the lock before throwing the error to prevent any state corruption.
  • Advanced Benchmark Suite for Conditions:
    • Added comprehensive "Cache Stampede Simulators" (PubSubScenario & ReaderWriterConditionScenario) to measure event loop queuing, task wake-up latency, and stampede protection.
    • Demonstrated up to 70x FASTER throughput compared to standard asyncio.Condition and threading.Condition in (1 Writer, 100 Readers) workloads.
  • Expanded Test Coverage:
    • Test suite expanded from 135 to 252 unit tests.
    • Added deep validation for state ownership, notify(n) precision, lock release safety, and timeout precision on both synchronous and asynchronous Condition proxies.

Updated

  • Reentrant Class Naming Convention:
    • Renamed all *SafeWriter classes to *ReentrantWriter (e.g., RWLockWriteSafeWriter -> RWLockWriteReentrantWriter) to better reflect their strictly nested, reentrant nature in the software engineering domain.
  • Documentation & README:
    • Added "Condition Memory vs CPU Trade-off" and "The Cost of Fairness" sections to the Architecture Limitations.
    • Expanded usage examples to cover Event-Driven Cache Refreshes, Precise Job Queues, and Condition-Based Atomic Downgrading patterns.