所以我有这样的功能read
,可以从多个线程同时调用。 而且我有一个函数来write
需要锁定所有的read
功能。 从哪里获得例如建立这样archetecture的?
我得到的,我们可以有:
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()
}
因此,如何做这种事?