假设我有一个 boost::multi_index_container 并想访问它的索引
boost::multi_index_container< ... > bmi;
// lock here?
auto &index = boost::multi_index::get<0>(bmi); // <-- does this call need to be protected by a lock?
// or is it sufficient to lock here?
// access the index (need to have the lock here)
当多个进程/线程访问一个 multi_indesx_container 时,我需要使用互斥锁(或类似的东西)。但是我是否也需要保护获取索引本身? 我猜不是,但无法在文档中找到保证。
最佳答案
虽然没有在任何地方记录,get()
是一个 static cast operation ,本质上是线程安全的。
关于c++ - 我是否需要通过锁来保护对 Boost MultiIndex 索引(索引本身)的访问?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53982289/