std::synchronized_value is a proposed new library type for the C++ standard.
This repo contains an example implementation of the current proposal.
The current proposal is described in documents number N4033 and p0290r4.
Slides from the lightning talk at CppCon '23
-
Make update_guard movable/swappable, to facility hand-over-hand locking.
-
Support for alternative mutex types, e.g.
std::shared_mutex,std::timed_mutex, etc. -
Support for conditional critical sections
-
Hierarchies of synchronized values, for working with arena allocators:
To read, only lock the value in read mode. To write, lock both the value and the arena in write mode.
Ansel Sermersheim talked about a similar construct with some extra features at CppCon 2017. The relevant bits are in part 2.
CppCon 2017: Ansel Sermersheim “Multithreading is the answer. What is the question? (part 1 of 2)”
CppCon 2017: Ansel Sermersheim “Multithreading is the answer. What is the question? (part 2 of 2)”