Open aaron-michaux opened 1 year ago
We have:
template<typename T> struct hash_trie_data { branch_node<T> const* m_root; size_t m_size; };
Then in the copy constructor, we copy as follows:
explicit hash_trie( hash_trie_data<T> const& data ) : m_data( data ) { addref( m_data.m_root ); } hash_trie( hash_trie<T> const& other ) : hash_trie( other.m_data ) {}
But, for example, insert:
template<typename U> auto insert( U &&value ) { if( auto newRoot = inserted( m_data.m_root, std::forward<U>(value) ) ) { release( m_data.m_root ); m_data = { newRoot, size()+1 }; } }
So... insert would race with copy construction on another thread. Give threads A and B
We have:
Then in the copy constructor, we copy as follows:
But, for example, insert:
So... insert would race with copy construction on another thread. Give threads A and B