Re[13]: volatile bool vs std::atomic_flag vs std::atomic<bool>
От: B0FEE664  
Дата: 01.09.15 17:02
Оценка:
Здравствуйте, uzhas, Вы писали:

U>Вильямс походу не в курсе о получении актуального значения через release/acquire : http://stackoverflow.com/questions/8819095/concurrency-atomic-and-volatile-in-c11-memory-model

U>

U>In the absence of any additional synchronization, if one thread writes a value to ai then there is nothing that guarantees that another thread will see the value in any given time period. The standard specifies that it should be visible "in a reasonable period of time", but any given access may return a stale value.


Ниже он пишет:

The only way to guarantee you have the "latest" value is to use a read-modify-write operation such as exchange(), compare_exchange_strong() or fetch_add(). Read-modify-write operations have an additional constraint that they always operate on the "latest" value, so a sequence of ai.fetch_add(1) operations by a series of threads will return a sequence of values with no duplicates or gaps. In the absence of additional constraints, there's still no guarantee which threads will see which values though.

И каждый день — без права на ошибку...
 
Подождите ...
Wait...
Пока на собственное сообщение не было ответов, его можно удалить.