C++: Thread-safe std::map with the speed of lock-free map

Introduction: Examples of use and testing of a thread-safe pointer and contention-free shared-mutex.  In this article we will show additional optimizations, examples of use and testing of a thread-safe pointer developed by us with an optimized shared mutex contfree_safe_ptr<T> - this is equivalent to safe_ptr<T, contention_free_shared_mutex<>>
In the end, we will show the comparative graphs of our thread-safe-pointer tests and some of the best lock-free algorithms from libCDS on Intel Core i5 / i7, Xeon, 2 x Xeon processors. You can find libCDS by the link:
In all benchmarks in this article used this commit of libCDS

Read full article:

Three related articles:
  1. We make any object thread-safe   2. We make a std::shared_mutex 10 times faster   3. Thread-safe st…

C++: We make a std::shared_mutex 10 times faster

Introduction: High performance of lock-based data structures. 
In this article, we will detail the atomic operations and C++11 memory barriers and the assembler instructions generated by it on x86_64 CPUs.

Next, we’ll show how to speed up the work of contfree_safe_ptr<std::map> up to the level of complex and optimized lock-free data structures that are similar to std::map<> in terms of their functionality, for example: SkipListMap and BronsonAVLTreeMap from libCDS library (Concurrent Data Structures library):
And we can get such multi-threaded performance for any of your initially non-thread-safe T-class used as contfree_safe_ptr<T>  –  it is  safe_ptr<T, contention_free_shared_mutex>  class, where contention_free_shared_mutex  is own optimized shared-mutex.
Namely, we will show how to realize your own high-performance contention-free shared-mutex, which almost does not conflict on readings. We implement our own active locks -…

C++: We make any object thread-safe

Introduction:  Smart pointer that makes any object thread-safe for any operations, with the performance equal to that of optimized lock-free containers. In these 3 articles I’ll tell in detail about atomic operations, memory barriers and the rapid exchange of data between threads, as well as about the “sequence-points” by the example of “execute-around-idiom”. At the same time, we will try to do something useful together.

There are no thread-safe containers (array, list, map ...) in the standard C++ library, which could be used in multiple threads without additional locks. In case of usage of standard containers for multithreading exchange, there is a danger for you to forget to protect one of the code sections with mutex or by mistake to protect it with another mutex.

Obviously, a developer will make more mistakes if he/she uses his/her own solution instead of a standard one. And if the task is so complex that there is no any standard solution, then the developer, while trying to fi…

The fastest interconnect for hundreds of CPUs, GPUs and FPGAs

About the fastest inter-server and inter-device communication with bandwidth more than 100 Gbit/sec and latency 0.5 usec