Skip to content

Commit

Permalink
Handle multiple action events with same tag.
Browse files Browse the repository at this point in the history
  • Loading branch information
erlingrj committed Nov 1, 2024
1 parent 50d4261 commit c852122
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions src/action.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,18 @@ void Action_prepare(Trigger *self, Event *event) {
LF_DEBUG(TRIG, "Preparing action %p", self);
Action *act = (Action *)self;
Scheduler *sched = &self->parent->env->scheduler;
self->is_present = true;
memcpy(act->value_ptr, event->payload, act->payload_pool.size);

if (self->is_present) {
LF_WARN(TRIG, "Action %p is already present at this tag. Its value was overwritten", self);
} else {
sched->register_for_cleanup(sched, self);

for (size_t i = 0; i < act->effects.size; i++) {
validaten(sched->reaction_queue.insert(&sched->reaction_queue, act->effects.reactions[i]));
}
}

self->is_present = true;
self->payload_pool->free(self->payload_pool, event->payload);
}

Expand Down

0 comments on commit c852122

Please sign in to comment.