title: LInux/c++, how to protect two data structures at same time?
body: <p>I'm developing some programs with c/c++ in Linux. my question is:</p>
  
  <ol>
  <li>I have an upper-level class called Vault, inside of which there are an OrderMap which uses unordered_map as data structure and a OrderBook, which has 2 std::list in side.</li>
  <li>Both the OrderMap and OrderBook stores Order* as the element, they share an Order object which is allocated on heap. So either the OrderBook or the OrderMap modifies the order within.</li>
  <li>I have two threads that will do read and write operations on them. the 2 threads can insert/modify/retrieve(read)/delete the elements.</li>
  </ol>
  
  <p>My Question is: how can I protect this big structure of "Vault"? I can actually protect the map or list, but I don't know how to protect them both at the same time. </p>
  
  <p>anybody gives me some ideas? </p>