Skip to content
/ cht Public
forked from Gregory-Meyer/cht

Lockfree resizeable concurrent hash table.

License

Notifications You must be signed in to change notification settings

Qi2013/cht

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

26 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

cht

crates.io docs.rs Travis CI

cht provides a lockfree hash table that supports fully concurrent lookups, insertions, modifications, and deletions. The table may also be concurrently resized to allow more elements to be inserted. cht also provides a segmented hash table using the same lockfree algorithm for increased concurrent write performance.

Usage

In your Cargo.toml:

cht = "^0.4.1"

Then in your code:

use cht::HashMap;

use std::{sync::Arc, thread};

let map = Arc::new(HashMap::new());

let threads: Vec<_> = (0..16)
    .map(|i| {
        let map = map.clone();

        thread::spawn(move || {
            const NUM_INSERTIONS: usize = 64;

            for j in (i * NUM_INSERTIONS)..((i + 1) * NUM_INSERTIONS) {
                map.insert_and(j, j, |prev| assert_eq!(prev, None));
            }
        })
    })
    .collect();

let _: Vec<_> = threads.into_iter().map(|t| t.join()).collect();

License

cht is licensed under the MIT license.

About

Lockfree resizeable concurrent hash table.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Rust 100.0%