Predefined key
tekjar opened this issue · 1 comments
tekjar commented
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
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.