Moritz escribió:
The reason why I asked if this is correct proceeding, is that I can observe the described behavior on my machine. Actually the writer is a write-only process whose writing frequency is not predictable.
So I tested this:
reader1->u_mtx.lock_sharable(); // does not block reader2->u_mtx.lock_sharable(); // does not block writer->u_mtx.lock(); // does block reader3->u_mtx.lock_sharable(); // does block (until the writer has finished its operation)
This is reproducible on my machine so I asked myself if this is the intended behavior. It would be exactly what I am looking for.
If the writer succeeds acquiring the exclusive lock (and to get this, it will need to wait until all readers finish their job), then every other attempt will block until the writer finishes. That's guaranteed. Regards, Ion