trie
trie copied to clipboard
Use of a Read Write Mutex
I was wondering if this library supports concurrency, and saw that a recent commit seems to imply that the support has been added: https://github.com/derekparker/trie/commit/1ce4922c7ad906a094c6298977755068ba76ad31
However, wouldn't your trie still be open to concurrent read operations while you have mutex locked Add
or Remove
. In that case, would it make sense to shift to sync.RWMutex
.
Also to support custom concurrent walks, it would make sense to have GetChild(rune) *Node
function instead of Children() map[rune]*Node
. So that a read lock can be taken inside GetChild
. Whereas, using Children()
would allow the caller to easily ignore an internal mutex lock.