Skip to content

Commit 85d54a4

Browse files
authored
Merge pull request #351 from lf-lang/initialize-recycle-q
Put a single event on the recycle queue initially to avoid runtime malloc
2 parents d454505 + b10e17b commit 85d54a4

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/reactor_common.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,13 @@ void _lf_initialize_timers(environment_t* env) {
549549
_lf_initialize_timer(env, env->timer_triggers[i]);
550550
}
551551
}
552+
553+
// To avoid runtime memory allocations for timer-driven programs
554+
// the recycle queue is initialized with a single event.
555+
if (env->timer_triggers_size > 0) {
556+
event_t *e = _lf_get_new_event(env);
557+
_lf_recycle_event(env, e);
558+
}
552559
}
553560

554561
/**

0 commit comments

Comments
 (0)