I am trying to use boost :: shared_mutex to implement a mutex with multiple readers / single writers. My question is pretty simple, is it possible for a thread to get reader access to shared_mutex when another thread tries to lock this shared_mutex for writing? For example, I have 10 threads, only one of them can write,
- In stream 1 there is shared_lock for this shared_mutex and is trying to read something
- In stream 2 there is shared_lock for this shared_mutex and is trying to read something
- thread 3 has a unique_lock on this shared_mutex and is trying to write something
- thread 4 has shared_lock for this shared_mutex and is trying to read something
- In thread 5 there is shared_lock for this shared_mutex and is trying to read something
Currently shared_mutex is shared by thread 2 lock, my question is, is it possible for thread 4 to have read access to this shared_mutex, before thread 3 can write? Is it possible for reader / writer mutexes to ever get into a fasting situation, for example, 100 readers are against. 1 writer?
Thanks.
source share