Skip to content

Commit

Permalink
Merge pull request #275 from lf-lang/unconnected-outputs
Browse files Browse the repository at this point in the history
Guard against unconnected outputs
  • Loading branch information
lhstrh authored Sep 18, 2023
2 parents c0da6ab + f0bd1bc commit 064e1ad
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 4 additions & 2 deletions core/reactor.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,14 @@ extern instant_t start_time;

/**
* Mark the given port's is_present field as true. This is_present field
* will later be cleaned up by _lf_start_time_step.
* will later be cleaned up by _lf_start_time_step. If the port is unconnected,
* do nothing.
* @param env Environment in which we are executing
* @param port A pointer to the port struct.
*/
void _lf_set_present(lf_port_base_t* port) {
environment_t *env = port->source_reactor->environment;
if (!port->source_reactor) return;
environment_t *env = port->source_reactor->environment;
bool* is_present_field = &port->is_present;
if (env->is_present_fields_abbreviated_size < env->is_present_fields_size) {
env->is_present_fields_abbreviated[env->is_present_fields_abbreviated_size]
Expand Down
6 changes: 4 additions & 2 deletions core/threaded/reactor_threaded.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,12 +210,14 @@ int _lf_wait_on_tag_barrier(environment_t* env, tag_t proposed_tag) {

/**
* Mark the given port's is_present field as true. This is_present field
* will later be cleaned up by _lf_start_time_step.
* will later be cleaned up by _lf_start_time_step. If the port is unconnected,
* do nothing.
* This assumes that the mutex is not held.
* @param port A pointer to the port struct.
*/
void _lf_set_present(lf_port_base_t* port) {
environment_t *env = port->source_reactor->environment;
if (!port->source_reactor) return;
environment_t *env = port->source_reactor->environment;
bool* is_present_field = &port->is_present;
int ipfas = lf_atomic_fetch_add(&env->is_present_fields_abbreviated_size, 1);
if (ipfas < env->is_present_fields_size) {
Expand Down

0 comments on commit 064e1ad

Please sign in to comment.