c++ - boost::dynamic_bitset multi thread issue -
i use boost::dynamic_bitset keep track of several tcp connections. if connected, set 1, otherwise, set 0. , each connection 1 thread. should need protect bit set multi thread? or not necessary since not modify size of bit set after created?
it's uncommon manipulate single bit when working in bitset. following things happen:
- load x bytes (x depends on machine , actual implementation)
- manipulate specific bit in bytes
- save x bytes in bitset's container.
this not boost::dynamic_bitset
specific, concerns std::bitset
example. should have @ documentation in case. since documentation doesn't mention explicit thread-safety, you're going have race condition.
so should protect bitset.
Comments
Post a Comment