From defe3ff38efa4f170237c917d839ce59015c7d83 Mon Sep 17 00:00:00 2001 From: Trent Houliston Date: Sat, 26 Oct 2024 11:43:41 +1100 Subject: [PATCH] fix postcondition --- src/dsl/word/Always.hpp | 2 +- src/dsl/word/IO.hpp | 2 +- src/dsl/word/Once.hpp | 4 ++-- src/util/CallbackGenerator.hpp | 18 +++++------------- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/src/dsl/word/Always.hpp b/src/dsl/word/Always.hpp index 24506c33..9292f739 100644 --- a/src/dsl/word/Always.hpp +++ b/src/dsl/word/Always.hpp @@ -110,7 +110,7 @@ namespace dsl { } template - static void postcondition(threading::ReactionTask& task) { + static void post_run(threading::ReactionTask& task) { // Get a task for the always reaction and submit it to the scheduler PowerPlant::powerplant->submit(task.parent->get_task()); } diff --git a/src/dsl/word/IO.hpp b/src/dsl/word/IO.hpp index 9b6e2648..6b7f3cb0 100644 --- a/src/dsl/word/IO.hpp +++ b/src/dsl/word/IO.hpp @@ -154,7 +154,7 @@ namespace dsl { } template - static void postcondition(threading::ReactionTask& task) { + static void post_run(threading::ReactionTask& task) { task.parent->reactor.emit(std::make_unique(task.parent->id)); } }; diff --git a/src/dsl/word/Once.hpp b/src/dsl/word/Once.hpp index d0bb339b..7699971f 100644 --- a/src/dsl/word/Once.hpp +++ b/src/dsl/word/Once.hpp @@ -35,13 +35,13 @@ namespace dsl { * * @code on() @endcode * Any reactions listed with this DSL word will run only once. - * This is the only time these reactions will run as the postcondition Unbinds the current reaction. + * This is the only time these reactions will run as the post_run Unbinds the current reaction. */ struct Once : Single { // Post condition to unbind this reaction. template - static void postcondition(threading::ReactionTask& task) { + static void post_run(threading::ReactionTask& task) { // Unbind: task.parent->unbind(); } diff --git a/src/util/CallbackGenerator.hpp b/src/util/CallbackGenerator.hpp index 5d3cbcf6..93ada18c 100644 --- a/src/util/CallbackGenerator.hpp +++ b/src/util/CallbackGenerator.hpp @@ -132,19 +132,11 @@ namespace util { // We have to catch any exceptions try { - // Create the scope object that wraps the execution of the callback - auto scope = DSL::scope(task); - - DSL::pre_run(task); - - // We call with only the relevant arguments to the passed function - util::apply_relevant(c, std::move(data)); - - // Run our postconditions - DSL::post_run(task); - - // Get rid of unused variable warning - std::ignore = scope; + auto scope = DSL::scope(task); // Acquire the scope + DSL::pre_run(task); // Pre run tasks + util::apply_relevant(c, std::move(data)); // Run the callback + DSL::post_run(task); // Post run tasks + std::ignore = scope; // Ignore unused variable warning } catch (...) { // Catch our exception if it happens