Skip to content

Commit

Permalink
fix postcondition
Browse files Browse the repository at this point in the history
  • Loading branch information
TrentHouliston committed Oct 26, 2024
1 parent 4a6ee21 commit defe3ff
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 17 deletions.
2 changes: 1 addition & 1 deletion src/dsl/word/Always.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ namespace dsl {
}

template <typename DSL>
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());
}
Expand Down
2 changes: 1 addition & 1 deletion src/dsl/word/IO.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ namespace dsl {
}

template <typename DSL>
static void postcondition(threading::ReactionTask& task) {
static void post_run(threading::ReactionTask& task) {
task.parent->reactor.emit<emit::Inline>(std::make_unique<IOFinished>(task.parent->id));
}
};
Expand Down
4 changes: 2 additions & 2 deletions src/dsl/word/Once.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -35,13 +35,13 @@ namespace dsl {
*
* @code on<Once>() @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 <typename DSL>
static void postcondition(threading::ReactionTask& task) {
static void post_run(threading::ReactionTask& task) {
// Unbind:
task.parent->unbind();
}
Expand Down
18 changes: 5 additions & 13 deletions src/util/CallbackGenerator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit defe3ff

Please sign in to comment.