I found myself in need of of a Readers-Writer mutex. With C++17 TR2 support not yet available in our compiler, I set out to implement std::shared_mutex
so that we have an easy upgrade path to the STL implementation once we get C++17 support, rather than rolling my own API.
In addition to std::shared_mutex
, we also need a Reader-Writer mutex that allows recursive locking for writers. Readers are always recursive any way. This is implemented as xtd::recursive_shared_mutex
this class has no equivalent in standard C++, but has the same API as std::shared_mutex
with some extensions.
In the code below, I use a custom class called xtd::fast_recursive_mutex
, this class is a fully compatible, drop-in-replacement for std::recursive_mutex
, but it uses CRITICAL_SECTION
on windows for faster locking than std::recursive_mutex
(at least on our compiler).
I found myself in need of of a Readers-Writer mutex. With C++17 TR2 support not yet available in our compiler, I set out to implement std::shared_mutex
so that we have an easy upgrade path to the STL implementation once we get C++17 support, rather than rolling my own API.
In addition to std::shared_mutex
we also need a Reader-Writer mutex that allows recursive locking for writers. Readers are always recursive any way. This is implemented as xtd::recursive_shared_mutex
this class has no equivalent in standard C++, but has the same API as std::shared_mutex
with some extensions.
In the code below I use a custom class called xtd::fast_recursive_mutex
, this class is a fully compatible, drop-in-replacement for std::recursive_mutex
, but it uses CRITICAL_SECTION
on windows for faster locking than std::recursive_mutex
(at least on our compiler).
I found myself in need of a Readers-Writer mutex. With C++17 TR2 support not yet available in our compiler, I set out to implement std::shared_mutex
so that we have an easy upgrade path to the STL implementation once we get C++17 support, rather than rolling my own API.
In addition to std::shared_mutex
, we also need a Reader-Writer mutex that allows recursive locking for writers. Readers are always recursive any way. This is implemented as xtd::recursive_shared_mutex
this class has no equivalent in standard C++, but has the same API as std::shared_mutex
with some extensions.
In the code below, I use a custom class called xtd::fast_recursive_mutex
, this class is a fully compatible, drop-in-replacement for std::recursive_mutex
, but it uses CRITICAL_SECTION
on windows for faster locking than std::recursive_mutex
(at least on our compiler).
In addition to std::shared_mutex
we also need a Reader-Writer mutex that allows recursive locking for writers. Readers are always recursive any way. This is implemented as xtd::recursive_shared_mutex
this class has no equivalent in standard C++, but has the same API as std::shared_mutex
with some extensions.
In the code below I use a custom class called xtd::fast_recursive_mutex
, this class is a fully compatible, drop-in-replacement for std::recursive_mutex
, but it uses CRITICAL_SECTION
on windows for faster locking than std::recursive_mutex
(at least on our compiler).
I'm interested in a review of correct operationcorrectness and any gross inefficiencies of the classes.
In addition to std::shared_mutex
we also need a Reader-Writer mutex that allows recursive locking for writers. Readers are always recursive any way. This is implemented as xtd::recursive_shared_mutex
this class has no equivalent in standard C++ but has the same API as std::shared_mutex
with some extensions.
In the code below I use a custom class called xtd::fast_recursive_mutex
, this class is a fully compatible, drop-in-replacement for std::recursive_mutex
but it uses CRITICAL_SECTION
on windows for faster locking than std::recursive_mutex
(at least on our compiler).
I'm interested in a review of correct operation and any gross inefficiencies of the classes.
In addition to std::shared_mutex
we also need a Reader-Writer mutex that allows recursive locking for writers. Readers are always recursive any way. This is implemented as xtd::recursive_shared_mutex
this class has no equivalent in standard C++, but has the same API as std::shared_mutex
with some extensions.
In the code below I use a custom class called xtd::fast_recursive_mutex
, this class is a fully compatible, drop-in-replacement for std::recursive_mutex
, but it uses CRITICAL_SECTION
on windows for faster locking than std::recursive_mutex
(at least on our compiler).
I'm interested in a review of correctness and any gross inefficiencies of the classes.