Suppose I have a std::map which is written by many threads concurrently. Looks like there is no lock-free map in C++ or boost yet.
I'm thinking of adding a boost::lockfree::queue before my map. One thread will be reading this queue and write to map, those threads that were writing to map now write to the queue:
[std::map] <- (lockfree::queue) <= threads
It seems the whole structure is lock free now, but it requires at least one condition variable and one mutex, so that when queue is not empty, the thread get notified and get data from queue.
Does it have better performance than simply using a std::lock_guard
when writing to map?