why C++0x standard committee rejected boost::share

2020-02-05 03:53发布

问题:

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.

回答1:

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.



回答2:

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.