Awesome Open Source
Awesome Open Source


License Cargo Documentation Continuous Integration

A concurrent, lock-free hash map for Rust.

This is an implementation of the lock-free hash map created by Dr. Cliff Click. Click released a talk about his hash map. Additionally, "reference" Java code is available here and more recently here.

Getting Started

This crate is available on

To use this crate in your project, add the following to your Cargo.toml file:

lockfreehashmap = "0.1"

and then add to your project root file:

extern crate lockfreehashmap;


extern crate lockfreehashmap;
use lockfreehashmap::LockFreeHashMap;

fn main() {
    let map = LockFreeHashMap::<u8, u8>::new();
    let insert_guard = lockfreehashmap::pin();
    for i in 1..4 {
        map.insert(i, i, &insert_guard);

    let map = &map;
    lockfreehashmap::scope(|scope| {
        // Spawn multiple threads, e.g. for a server that executes some actions on a loop
        for _ in 0..16 {
            scope.spawn(|| {
                loop {
                    let mut line = String::new();
                    ::std::io::stdin().read_line(&mut line).unwrap();
                    let mut iter = line.split_whitespace();
                    let command: &str =;
                    let key: u8 =;
                    let value: u8 =;
                    let guard = lockfreehashmap::pin();
                    let _result = match command {
                        "insert" => map.insert(key, value, &guard),
                        _ => unimplemented!(),


Documentation is available on

Developer documentation of private types is available here.


To use valgrind, add the following lines to the top of the src/ file.

#![feature(alloc_system, global_allocator, allocator_api)]
extern crate alloc_system;
use alloc_system::System;
static A: System = System;

Then call valgrind --leak-check=full --show-leak-kinds=all ./target/debug/deps/lockfreehashmap-*


GNU Lesser General Public License v3.0 or any later version

See LICENSE and LICENSE.LESSER for details.

Get A Weekly Email With Trending Projects For These Topics
No Spam. Unsubscribe easily at any time.
rust (4,469
lock-free (36
hashmap (24

Find Open Source By Browsing 7,000 Topics Across 59 Categories