title: Is it possible to implement lock free map in C++
body: <p>We are developing a network application based C/S, we find there are too many locks adding to std::map that the performance of server became poor. </p>
  
  <p>I wonder if it is possible to implement a lock-free map, if yes, how? Is there any open source code there?</p>
  
  <p>EDIT:
  Actually we use the std::map to store sockets information, we did encapsulation based on the socket file description to include some other necessary information such as ip address, port, socket type, tcp or udp, etc. </p>
  
  <p>To summary, we have a global map say it's</p>
  
  <pre><code>map&lt;int fileDescriptor, socketInfor*&gt; SocketsMap, 
  </code></pre>
  
  <p>then every thread which is used to send data needs to access SocketsMap, and they have to add mutex before reading from SocketsMap or writing to SocketsMap, thus the concurrency level of the whole application would be greatly decreased because of so many locks addding to SocketsMap.</p>
  
  <p>To avoid the concurrency level problem, we have two solutions: 1. store each socketInfor* separately 2. use some kind of lock-free map. </p>
  
  <p>I would like to find some kind of lock-free map, because codes changes required by this solution are much less than that of solution 1. </p>