How to implement a reader-writer lock with quick response to writer?
Question:
How to implement a reader-writer lock with quick response to writer?
I am using boost1.35.0. I know 1.36.0 is available, but I failed to build
regex in 1.36.0 with VC8.
I have the following requirements:
1.There are several reader threads and a single writer thread. The writer
thread will update shared data periodically. And reader threads may read
shared data at any time.
2.As long as writer thread try to update data, all reader thread should be
blocked as soon as possible.
3.And reader thread should be blocked during data updating.
4.But reader threads can't be interrupted when they are reading.
(i.e. all upcoming reader threads should be blocked, but writer still need
wait till the last reader thread in reading finished.)
How to implement above scenario with quick response to writer thread?
I tried to write the following program to test shared_mutex, but it seems it
can't meet my requirement:
#include <iostream>
using namespace std;
#include
participants (1)
-
Bill David