bitcoinleveldb-sync

Crates.iobitcoinleveldb-sync
lib.rsbitcoinleveldb-sync
version0.1.19
created_at2023-01-19 07:18:54.268596+00
updated_at2025-12-01 17:55:50.843193+00
descriptionRust crate for efficient, scoped synchronization using 'parking_lot' raw mutexes.
homepage
repositoryhttps://github.com/klebs6/bitcoin-rs
max_upload_size
id762376
size176,691
(klebs6)

documentation

https://docs.rs/bitcoinleveldb-sync

README

bitcoinleveldb-sync

bitcoinleveldb-sync is a Rust library designed for synchronizing access to resources using a custom lock mechanism. This crate utilizes low-level, high-performance locking principles and is ideal for scenarios that require precise, synchronous control over concurrency.

Overview

This crate provides a synchronization primitive: MutexLock, which relies on a low-level parking_lot::RawMutex. This allows for more granular control over locking behavior compared to standard library mutexes. Users are responsible for ensuring correctness when employing these advanced locking techniques.

Core Features

  • Scoped Locking: The MutexLock is scoped, automatically releasing the lock when it goes out of scope, preventing deadlocks.
  • High-Performance: Utilizing parking_lot for highly efficient lock operations suitable for performance-critical applications.

Usage

Here is an example of using MutexLock:

use parking_lot::RawMutex;

let raw_mutex = RawMutex::INIT;

{
    let _lock = bitcoinleveldb_sync::MutexLock::new(&raw_mutex);
    // critical section
}
// The lock is automatically released here.

Safety

  • The MutexLock requires users to provide raw pointers to parking_lot::RawMutex. Proper pointer management and safety practices are expected.

  • Panic Safety: The constructor will panic if given a null pointer.

Contributing

Contributions and issues are welcome. Please see the repository for more information.

Commit count: 0

cargo fmt