sile / patricia_tree

A memory-efficient patricia tree implementation written in Rust
MIT License
111 stars 17 forks source link

Is it safe to share a read only PatriciaMap across multiple thread? #9

Closed 12101111 closed 3 years ago

12101111 commented 4 years ago

In another word, is it safe to add unsafe impl<V> Sync for Node<V> {} ?

sile commented 4 years ago

I'm not 100% sure but it seems okay to implement Sync for Node<V>.

leshow commented 3 years ago

You need to implement it like,

unsafe impl<V: Sync> Sync for Node<V> {}
unsafe impl<V: Send> Send for Node<V> {}

which is something I got wrong initially. It's not unconditionally Send or Sync, only if V is also

sile commented 3 years ago

@leshow You're right. Thank you for your advice!