5 ms·
Some options: - Make sure no one mutates the slice ever, making it safe to read - Guarding the slice behind a mutex, requiring anyone who reads or writes it t
by sapiogram 1y ago
Some options:
- Make sure no one mutates the slice ever, making it safe to read
- Guarding the slice behind a mutex, requiring anyone who reads or writes it to lock the mutex first
- Using some kind of thread-safe slice implementation
- sirgallo 1y agoI went with option 1. On a mutation, I do a complete node copy where I also copy the key/value slices. When I set a child node for the first time or update a child, I create a branch new leaf node with a copy of the key/value. This way previous nodes maintain the original copy.