hawkw / sharded-slab

a lock-free concurrent slab (experimental)
MIT License
269 stars 17 forks source link

Predefined key #13

Closed tekjar closed 4 years ago

tekjar commented 4 years ago

Is it possible to predefine a key so that works like a concurrent map?

slab.insert("key", "hello world").unwrap();
assert_eq!(slab.get("key").unwrap(), "hello world");
hawkw commented 4 years ago

No, the slab is not a concurrent map: keys are always usize and are generated by the slab when inserting objects. This crate is intended to be used for managing preallocated memory concurrently, not as a general-purpose data structure — I suspect it could potentially be useful as an implementation detail in a concurrent map implementation, though!

You might want to look into another crate, such as evmap, chashmap, or concache, all of which implement concurrent maps — which one is right for you depends on your use case.