Skip to content

NoXF/lockfreehashmap-rs

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

50 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

LockFreeHashMap-rs

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 crates.io.

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

[dependencies]
lockfreehashmap = "0.1"

and then add to your project root file:

extern crate lockfreehashmap;

Example

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);
    }
    drop(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 = iter.next().unwrap();
                    let key: u8 = iter.next().unwrap().parse().unwrap();
                    let value: u8 = iter.next().unwrap().parse().unwrap();
                    let guard = lockfreehashmap::pin();
                    let _result = match command {
                        "insert" => map.insert(key, value, &guard),
                        _ => unimplemented!(),
                    };
                }
            });
        }
    });
}

Documentation

Documentation is available on docs.rs.

Developer documentation of private types is available here.

License

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

See LICENSE and LICENSE.LESSER for details.

About

A concurrent lock-free hash map for Rust.

Resources

License

GPL-3.0, LGPL-3.0 licenses found

Licenses found

GPL-3.0
LICENSE
LGPL-3.0
LICENSE.LESSER

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Rust 98.1%
  • Shell 1.9%