michaelsproul / rust_radix_trie

Fast generic radix trie implemented in Rust
https://docs.rs/radix_trie/
MIT License
184 stars 32 forks source link

Does this library support multithreading? #58

Closed Maimonator closed 4 years ago

Maimonator commented 4 years ago

Hey! I've been wondering if this library supports multithreading in rust. Thanks! :)

michaelsproul commented 4 years ago

Hey. The data structure isn't explicitly concurrent, but there shouldn't anything be anything stopping it from being used in a multi-threaded context. The usual ways of synchronising access with a mutex or read-write lock should work. I'm quite fond of the parking_lot crate, which has fast and easy to use implementations of Mutex and RwLock. You could create a trie: RwLock<Trie<K, V>>, and then use methods like trie.read().get() and trie.write().get_mut(), etc.

Does that answer your question?

Maimonator commented 4 years ago

This was such a great answer with lots of information. Thanks a lot!!!

michaelsproul commented 4 years ago

No worries! Glad I could help :)