Skip to content

Commit

Permalink
Cleaned up lf_get_federation_id
Browse files Browse the repository at this point in the history
  • Loading branch information
edwardalee committed Dec 8, 2024
1 parent 5a02d08 commit 7723bdb
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 47 deletions.
2 changes: 1 addition & 1 deletion core/src/main/resources/lib/c/reactor-c
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,6 @@ target C {
preamble {=
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif

const char* lf_get_federation_id();

#ifdef __cplusplus
}
#endif
=}

/** Persistent federate that is responsible for lauching the transient federate */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,6 @@ import Middle from "TransientDownstreamWithTimer.lf"
preamble {=
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif

const char* lf_get_federation_id();

#ifdef __cplusplus
}
#endif
=}

/** Persistent federate that is responsible for lauching the transient federate */
Expand Down
9 changes: 0 additions & 9 deletions test/C/src/federated/transient/TransientHotSwap.lf
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,6 @@ import Down from "TransientDownstreamWithTimer.lf"
preamble {=
#include <stdlib.h>
#include <string.h>
#ifdef __cplusplus
extern "C" {
#endif

const char* lf_get_federation_id();

#ifdef __cplusplus
}
#endif
=}

/** Persistent federate that is responsible for lauching the transient federate */
Expand Down
25 changes: 6 additions & 19 deletions test/C/src/federated/transient/TransientStatePersistence.lf
Original file line number Diff line number Diff line change
@@ -1,30 +1,17 @@
/**
* This LF program showcases and tests the persistance of the internal state of a transient federate
* across executions. Using the hot swap mechanism, the transient federate `Middle` leaves and then
* joins. Whenever the state to save changes (of type `federate_state_t`), it notifies
* `Persistence`. `Middle` notifies `Persistence` also when it joins. When it joins the second time
* or after, it receives the saved state and sets it. In this, the order of the reactions is
* important.
* joins. Whenever the state (of type `federate_state_t`) changes, it notifies `Persistence`. `Middle`
* notifies `Persistence` also when it joins. When `Middle` joins the second time or after, it receives
* the saved state and sets it. In this, the order of the reactions is important.
*/
target C {
timeout: 2900 ms,
logging: LOG
timeout: 2900 ms
}

preamble {=
#include <stdlib.h>
#include <string.h>

#ifdef __cplusplus
extern "C" {
#endif

const char* lf_get_federation_id();

#ifdef __cplusplus
}
#endif

// The internal federate state to be persistent across executions
typedef struct federate_state_t {
char state_char;
Expand Down Expand Up @@ -81,7 +68,7 @@ reactor Persistence {
reaction(in_from_middle) {=
self->middle_state.state_char = in_from_middle->value.state_char;
self->middle_state.state_count = in_from_middle->value.state_count;
lf_print("Latest recieved state: {%c,%d}", self->middle_state.state_char,
lf_print("Latest received state: {%c,%d}", self->middle_state.state_char,
self->middle_state.state_count);
=}
}
Expand Down Expand Up @@ -139,7 +126,7 @@ reactor Middle {

reaction(in_from_persistence) {=
self->middle_state = in_from_persistence->value;
lf_print("Recieved the latest state of: {%c,%d} at " PRINTF_TIME ".",
lf_print("Received the latest state of: {%c,%d} at " PRINTF_TIME ".",
self->middle_state.state_char,
self->middle_state.state_count,
lf_time_logical_elapsed());
Expand Down

0 comments on commit 7723bdb

Please sign in to comment.