我想鎖定按鍵/指數在另一張圖是這樣的:如何使用boost :: mutex作爲std :: map中的映射類型?
std::map<int, boost::mutex> pointCloudsMutexes_;
pointCloudsMutexes_[index].lock();
不過,我收到以下錯誤:
/usr/include/c++/4.8/bits/stl_pair.h:113: error: no matching function for call to 'boost::mutex::mutex(const boost::mutex&)'
: first(__a), second(__b) { }
^
這似乎與std::vector
工作,但不std::map
。我究竟做錯了什麼?
有人想知道什麼要求導致了設計決定,即互斥鎖地圖是一種有效的解決方案。有可能有一個更加優雅的方式來實現你想要的。 –
併發散列映射 – Raaj
本設計不會是並行散列映射。這將是一個非併發的互斥鎖地圖。你需要包裹整個地圖,並用一個互斥鎖保護它。 –