diff --git a/ClockReceiver/JustInTime.hpp b/ClockReceiver/JustInTime.hpp index 040b26e4d..939ff0684 100644 --- a/ClockReceiver/JustInTime.hpp +++ b/ClockReceiver/JustInTime.hpp @@ -14,6 +14,8 @@ #include "ClockingHintSource.hpp" #include "ForceInline.hpp" +#include + /*! A JustInTimeActor holds (i) an embedded object with a run_for method; and (ii) an amount of time since run_for was last called. @@ -121,7 +123,13 @@ template () { +#ifndef NDEBUG + assert(!flush_concurrency_check_.test_and_set()); +#endif flush(); +#ifndef NDEBUG + flush_concurrency_check_.clear(); +#endif return std::unique_ptr(&object_, SequencePointAwareDeleter(this)); } @@ -130,7 +138,13 @@ template () const { auto non_const_this = const_cast *>(this); +#ifndef NDEBUG + assert(!non_const_this->flush_concurrency_check_.test_and_set()); +#endif non_const_this->flush(); +#ifndef NDEBUG + non_const_this->flush_concurrency_check_.clear(); +#endif return std::unique_ptr(&object_, SequencePointAwareDeleter(non_const_this)); } @@ -264,6 +278,10 @@ template