【发布时间】:2023-12-28 00:53:01
【问题描述】:
所以我有像read 这样可以从多个线程同时调用的函数。但我也有一个write 的函数,它需要锁定所有read 函数。在哪里可以获得创建这种架构的示例?
我知道我们可以拥有:
mutable boost::mutex the_read_mutex;
mutable boost::mutex the_write_mutex;
和:
void write()
{
// make all new readers wait and wait for all other currently running read threads();
}
void read()
{
// do not make all new readers wait, and wait for all currently running write thread()
}
那么怎么做呢?
【问题讨论】:
标签: c++ multithreading boost mutex mutable