I’m not sure that problem 3 needs any solution at all, particularly a read-write lock. If a thread is updating the old set of bits when it’s time for a switch, just let it complete that write to the older set in parallel with the swap. Since the read path checks older sets of bits in any case, it really doesn’t matter if the bit is set in the latest bit-set or the older bit-set. Yes, it might age out slightly faster, but it would have done that anyway if the write had arrived a millisecond before the aging timer fired. If that bothers you, keep more old bit sets around and age them out faster.