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:

  1. load x bytes (x depends on machine , actual implementation)
  2. manipulate specific bit in bytes
  3. 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

Popular posts from this blog

java.util.scanner - How to read and add only numbers to array from a text file -

rewrite - Trouble with Wordpress multiple custom querystrings -