Skip to content

Commit

Permalink
Merge pull request #351 from lf-lang/initialize-recycle-q
Browse files Browse the repository at this point in the history
Put a single event on the recycle queue initially to avoid runtime malloc
  • Loading branch information
erlingrj authored Feb 7, 2024
2 parents d454505 + b10e17b commit 85d54a4
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions core/reactor_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -549,6 +549,13 @@ void _lf_initialize_timers(environment_t* env) {
_lf_initialize_timer(env, env->timer_triggers[i]);
}
}

// To avoid runtime memory allocations for timer-driven programs
// the recycle queue is initialized with a single event.
if (env->timer_triggers_size > 0) {
event_t *e = _lf_get_new_event(env);
_lf_recycle_event(env, e);
}
}

/**
Expand Down

0 comments on commit 85d54a4

Please sign in to comment.