摘要: 翻译自:https://stackoverflow.com/questions/3652056/how efficient is locking an unlocked mutex what is the cost of a mutex 一个锁,锁很多数据;还是一个数据一个锁? 如果有很多线程频繁的 阅读全文
posted @ 2020-02-24 22:01 ConfuciusPei 阅读(782) 评论(0) 推荐(0) 编辑
摘要: std::mutex mutex代表的是MUTual EXclusive(禁止同时访问),通过memory barrier来实现。不同平台实现不一样,这里不深究了。 线程安全队列 使用std::lock_guard,不需要主动unlock了 std::unique_lock可以通过unlock来解锁 阅读全文
posted @ 2020-02-24 15:31 ConfuciusPei 阅读(166) 评论(0) 推荐(0) 编辑