Ensures deterministic initial state for the atomic flag.
This commit is contained in:
1 parent
dbbea78b76
commit
adb3811847
2 files changed
+7
No files matched your search
@@ -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;
|
||||||
|
|||||||
Reference in new issue
Block a user