Closed krsvital closed 7 years ago
or can you do implementation itarerators on unlocked table for reading?
@dnbh is correct. The reason iteration is done through the locked table, is that iterators can be invalidated by other concurrent operations on the table, such as inserts and deletions. The interface for locked_table actually emulates exactly the interface for std::unordered_map, so iteration should work exactly the same way as it does in STL.
Regarding support for operator=
, we currently only support moving the locked table to another locked_table
object, and not copying, or copying into a different type. Your best bet for copying the table data into an instance of std::map
is to iterate through the locked_table
, and insert every key-value pair individually. There really wouldn't be a more efficient way to do this anyways.
my example:
typedef cockoohash_map<std::string, int> cockoo_map; std::map<std::string, int> my_map;
cockoo_map tbl;
auto lt = tbl.lock_table(); my_map = lt; //its not working, no implementation of operator= lt.unlock();
can you add support this? somtimes needs to work with unlocked tables, becouse if its locked CPU time is greatly increased.