1
0
mirror of https://github.com/TomHarte/CLK.git synced 2024-06-01 06:41:36 +00:00

Ensures deterministic initial state for the atomic flag.

This commit is contained in:
Thomas Harte 2017-11-13 22:51:42 -05:00
parent dbbea78b76
commit adb3811847
2 changed files with 7 additions and 0 deletions

View File

@ -12,6 +12,11 @@
using namespace Concurrency;
BestEffortUpdater::BestEffortUpdater() {
// ATOMIC_FLAG_INIT isn't necessarily safe to use, so establish default state by other means.
update_is_ongoing_.clear();
}
void BestEffortUpdater::update() {
// Perform an update only if one is not currently ongoing.
if(!update_is_ongoing_.test_and_set()) {

View File

@ -25,6 +25,8 @@ namespace Concurrency {
*/
class BestEffortUpdater {
public:
BestEffortUpdater();
/// A delegate receives timing cues.
struct Delegate {
virtual void update(BestEffortUpdater *updater, int cycles, bool did_skip_previous_update) = 0;