From f38cf91ea7c2cedad9b120bcc40b52b53e82dfcb Mon Sep 17 00:00:00 2001 From: Thomas Harte Date: Tue, 14 Feb 2023 20:13:16 -0500 Subject: [PATCH] Add attempt to detect improper usage. --- ClockReceiver/JustInTime.hpp | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) 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