#hash-map #locking #thread-safe #level #exclusive

lockmap

A high-performance, thread-safe HashMap implementation for Rust that provides fine-grained locking at the key level

12 releases

0.1.11 Jun 9, 2025
0.1.10 May 28, 2025
0.1.9 Feb 19, 2025
0.1.7 Jan 23, 2025
0.1.1 Nov 22, 2024

#391 in Concurrency

Download history 737/week @ 2025-03-03 487/week @ 2025-03-10 291/week @ 2025-03-17 172/week @ 2025-03-24 132/week @ 2025-03-31 164/week @ 2025-04-07 144/week @ 2025-04-14 91/week @ 2025-04-21 39/week @ 2025-04-28 111/week @ 2025-05-05 230/week @ 2025-05-12 72/week @ 2025-05-19 216/week @ 2025-05-26 136/week @ 2025-06-02 173/week @ 2025-06-09 58/week @ 2025-06-16

587 downloads per month
Used in r2pc

MIT/Apache

53KB
1K SLoC

lockmap

Rust codecov Crates.io Documentation FOSSA Status

A high-performance, thread-safe HashMap implementation for Rust that provides fine-grained locking at the key level.

Usage

use lockmap::LockMap;

// Create a new lock map
let map = LockMap::<String, String>::new();

// Set a value
map.insert_by_ref("key", "value".into());

// Get a value
assert_eq!(map.get("key"), Some("value".into()));

// Use entry API for exclusive access
{
    let mut entry = map.entry_by_ref("key");
    assert_eq!(entry.get().as_deref(), Some("value"));
    entry.insert("new value".to_string());
}

// Remove a value
assert_eq!(map.remove("key"), Some("new value".into()));

License

FOSSA Status

Dependencies

~0–11MB
~51K SLoC