Skip to content

Commit

Permalink
splitting reaction body into wrapper and body
Browse files Browse the repository at this point in the history
  • Loading branch information
tanneberger committed Sep 27, 2024
1 parent 7add40d commit 24bfa8c
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions examples/posix/timer_ex.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,19 @@ struct MyReactor {
Trigger *_triggers[1];
};

void timer_handler(Reaction *_self) {
struct MyReactor *self = (struct MyReactor *)_self->parent;
void reaction_0_body(struct MyReactor* self, MyTimer* my_timer) {
printf("Hello World @ %ld\n", self->super.env->current_tag.time);
}

void reaction_0_wrapper(Reaction *_self) {
struct MyReactor *self = (struct MyReactor *)_self->parent;
MyTimer* my_timer = &self->timer;

reaction_0_body(self, my_timer);
}

void MyReaction_ctor(MyReaction *self, Reactor *parent) {
Reaction_ctor(&self->super, parent, timer_handler, NULL, 0, 0);
Reaction_ctor(&self->super, parent, reaction_0_wrapper, NULL, 0, 0);
}

void MyReactor_ctor(struct MyReactor *self, Environment *env) {
Expand Down

0 comments on commit 24bfa8c

Please sign in to comment.