Stl: P1135R6 The C++20 Synchronization Library

Created on 6 Sep 2019  路  4Comments  路  Source: microsoft/STL

P1135R6 The C++20 Synchronization Library
P1643R1 Adding wait/notify To atomic_ref
P1644R0 Adding wait/notify To atomic<shared_ptr<T>>, atomic<weak_ptr<T>>
P1865R1 Adding max() To latch And barrier

The IDE's list of extensionless headers has been updated for VS 2019 16.5.

Feature-test macros as of WG21-N4842:

#define __cpp_lib_atomic_lock_free_type_aliases 201907L
#define __cpp_lib_atomic_flag_test 201907L
#define __cpp_lib_atomic_wait 201907L
#define __cpp_lib_semaphore 201907L
#define __cpp_lib_latch 201907L
#define __cpp_lib_barrier 201907L
cxx20 fixed

All 4 comments

@StephanTLavavej , I think this should be marked as work in progress, or, more precisely, need information.

593 is atomic wait, and all remaining parts of C++20 Synchronization Library should probably be implemented based on atomic wait (no mater by using std::atomic or by calling these APIs), because other ways are less appealing:

  • Windows Semaphores implementation will be subject to low resource condition, which should be avoided
  • Vista+ Synchronization Barrier does not have all features of C++ std::barrier (no arrive_and_drop at least), and even std::latch (no count down).
  • SRW Lock seems to work as binary semaphore, not only as a mutex, but this is not documented anywhere. So SRW Lock implementation would use SRW Lock only as a mutex, which looks like reimplementing the same fallback that is in #593

Ultimately, atomic wait progress is blocked on lack of information about Windows API, so looks like entire P1135R6 work is blocked on that.

@AlexGuteniev - done, thanks :smile_cat:

I think, info needed can be removed. Atomic wait is in ready for review state, after it is committed, the rest are unblocked.

So, currently the status I think is work in progress:

  1. small part of P1135R6 is already done (atomic flag test, lock-free types)
  2. waiting on #593 to arrive to master, remaining is leaf, this will be a base part of P1135R6
  3. the remaining part of P1135R6 is in #1057 , it will be ready for review when re-merged against master with wait on address in
  4. P1643R1 (atomic wait for atomic_ref) will be done is scope of #843 , there is some amount of work, mostly due to exposing 16 bytes lock-free type in atomic ref change
  5. P1644R0 atomic wait for atomic_shared_ptr - did not think about it yet, but seems easy after atomic wait and atomic ref are there.
  6. Finally, P1865R1 Adding max() would be done along with latch and barrier. It is actually currently essential for barrier, since my design decision was to spend more than one bit of size_t on state information, so max() for barrier is less than max ptrdiff_t value.
Was this page helpful?
0 / 5 - 0 ratings