#synchronization-primitive #version #unsync #atomic-waker #flags #atomic-bool #arc #async-mutex

synchrony

A library that provides both sync and unsync versions of common synchronization primitives

6 releases

Uses new Rust 2024

new 0.1.6 Mar 6, 2026
0.1.5 Mar 5, 2026
0.1.4 Feb 24, 2026
0.1.1 Jan 18, 2026

#320 in Concurrency

Download history 1607/week @ 2026-01-16 2087/week @ 2026-01-23 2208/week @ 2026-01-30 3616/week @ 2026-02-06 4485/week @ 2026-02-13 4897/week @ 2026-02-20 9068/week @ 2026-02-27

23,037 downloads per month
Used in 35 crates (4 directly)

MIT license

59KB
1K SLoC

Synchrony

MIT licensed crates.io docs.rs Check Telegram Discord

A library that provides both sync and unsync versions of common synchronization primitives.

Features

All of the following primitives are provided in both sync and unsync versions:

  • Shared (Rc/Arc)
  • Atomic Scalars
  • Watch
  • Waker Slot (AtomicWaker and its unsync counterpart)
  • Mutex
  • Async Mutex
  • BiLock
  • Flag (specialized AtomicBool)
  • Event (event-listener and local-event)
  • Async Flag

Loom Testing Support

This library includes built-in support for loom, a testing tool for concurrent Rust code that helps verify the correctness of concurrent algorithms.

When compiled with --cfg loom, the library automatically switches to use loom's implementations of synchronization primitives instead of the standard library versions. This enables you to:

  • Detect data races and concurrency bugs
  • Verify lock-free algorithms
  • Test different thread interleavings exhaustively

For more information about loom and how to write loom tests, see the loom documentation.

Supported Types

The following types automatically use loom implementations when the loom cfg is enabled:

  • std::sync::atomic::* types (AtomicBool, AtomicUsize, etc.)
  • std::sync::Arcloom::sync::Arc
  • std::sync::Mutexloom::sync::Mutex
  • std::cell::UnsafeCellloom::cell::UnsafeCell
  • std::cell::Cellloom::cell::Cell

Dependencies

~0–6.5MB
~107K SLoC