samedi 12 décembre 2020

C++ release sequence details

C++ concurrency in action

I learned that the purpose of the release sequence is to make a write operation in one thread sync with many read operations in other threads.

But I still can not understand some details after reading two reference items below.

cppreference

  1. Writes performed by the same thread that performed A (until C++20)
  2. Atomic read-modify-write operations made to M by any thread

1.Dose "Writes performed by the same thread" mean something like below?

void foo()
{
    count.store(release)
    ....
    count.store(release)
}

Why emphasize a write operation in the same thread? And why only emphasize a write(not read) operation?

2.Do operations in other thread must RMW like atomic::fetch_sub ? Can it be a normal read operation like atomic::load?

Aucun commentaire:

Enregistrer un commentaire