Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why C++0x standard committee rejected boost::shared_mutex?

do you have any info about the subject? any problem with boost::shared_mutex in particular and with reader-writer mutexes at all?

reader-writer mutex can be misused, e.g. frequent writer locks reduces performance, even in comparison with simple mutex. but there're a lot of cases when many readers often require a shared resource that can be modified by writer really infrequently.

like image 845
Andriy Tylychko Avatar asked Jan 11 '11 15:01

Andriy Tylychko


2 Answers

Anthony Williams is an influential member of the C++ standards committee. He co-authored many of the proposals that led to the inclusion of the thread library in the C++11 Standard. You can read his objections in this commentary. Nevertheless, it did make it into C++17.

like image 52
Hans Passant Avatar answered Dec 09 '22 04:12

Hans Passant


As told in the mail referenced by Hans, the problem with shared_mutex is its high overhead. Therefore shared_mutex gives only a benefit when resources are held for a long time and only few threads are competing for the resources, which is very rare.

I found another detailed article about the issue.

like image 43
Enno Gröper Avatar answered Dec 09 '22 04:12

Enno Gröper