mirror of
https://github.com/TomHarte/CLK.git
synced 2025-02-09 17:31:18 +00:00
Ensures deterministic initial state for the atomic flag.
This commit is contained in:
parent
dbbea78b76
commit
adb3811847
@ -12,6 +12,11 @@
|
|||||||
|
|
||||||
using namespace Concurrency;
|
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() {
|
void BestEffortUpdater::update() {
|
||||||
// Perform an update only if one is not currently ongoing.
|
// Perform an update only if one is not currently ongoing.
|
||||||
if(!update_is_ongoing_.test_and_set()) {
|
if(!update_is_ongoing_.test_and_set()) {
|
||||||
|
@ -25,6 +25,8 @@ namespace Concurrency {
|
|||||||
*/
|
*/
|
||||||
class BestEffortUpdater {
|
class BestEffortUpdater {
|
||||||
public:
|
public:
|
||||||
|
BestEffortUpdater();
|
||||||
|
|
||||||
/// A delegate receives timing cues.
|
/// A delegate receives timing cues.
|
||||||
struct Delegate {
|
struct Delegate {
|
||||||
virtual void update(BestEffortUpdater *updater, int cycles, bool did_skip_previous_update) = 0;
|
virtual void update(BestEffortUpdater *updater, int cycles, bool did_skip_previous_update) = 0;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user