reactor-c
C Runtime for Lingua Franca
|
Definitions for the C target of Lingua Franca shared by threaded and unthreaded versions. More...
#include "lf_types.h"
#include "modes.h"
#include "port.h"
#include "tag.h"
#include "clock.h"
#include "tracepoint.h"
#include "util.h"
Go to the source code of this file.
Macros | |
#define | SUPPRESS_UNUSED_WARNING(x) |
Macro to suppress warnings about unused variables. | |
Functions | |
bool | lf_is_tag_after_stop_tag (environment_t *env, tag_t tag) |
Return true if the provided tag is after stop tag. | |
void | lf_set_present (lf_port_base_t *port) |
Mark the given port's is_present field as true. | |
void | lf_set_stop_tag (environment_t *env, tag_t tag) |
Set the stop tag if it is less than the stop tag of the specified environment. | |
void | lf_print_snapshot (environment_t *env) |
Print a snapshot of the priority queues used during execution (for debugging). | |
void | lf_request_stop (void) |
Request a stop to execution as soon as possible. | |
void * | lf_allocate (size_t count, size_t size, struct allocation_record_t **head) |
Allocate memory and record on the specified allocation record (a self struct). | |
self_base_t * | lf_new_reactor (size_t size) |
Allocate memory for a new runtime instance of a reactor. | |
void | lf_free_all_reactors (void) |
Free all the reactors that are allocated with lf_new_reactor(size_t) . | |
void | lf_free_reactor (self_base_t *self) |
Free the specified reactor. | |
Definitions for the C target of Lingua Franca shared by threaded and unthreaded versions.
This header file defines functions that programmers use in the body of reactions for reading and writing inputs and outputs and scheduling future events. Other functions that might be useful to application programmers are also defined here.
Many of these functions have macro wrappers defined in reaction_macros.h.
#define SUPPRESS_UNUSED_WARNING | ( | x | ) |
Macro to suppress warnings about unused variables.
void * lf_allocate | ( | size_t | count, |
size_t | size, | ||
struct allocation_record_t ** | head ) |
Allocate memory and record on the specified allocation record (a self struct).
This will allocate memory using calloc (so the allocated memory is zeroed out) and record the allocated memory on the specified self struct so that it will be freed when calling free_reactor(self_base_t)
.
count | The number of items of size 'size' to accomodate. |
size | The size of each item. |
head | Pointer to the head of a list on which to record the allocation, or NULL to not record it (an allocation_record_t** ), |
void lf_free_all_reactors | ( | void | ) |
Free all the reactors that are allocated with lf_new_reactor(size_t)
.
void lf_free_reactor | ( | self_base_t * | self | ) |
Free the specified reactor.
This will free the memory recorded on the allocations list of the specified reactor and then free the specified self struct.
self | The self struct of the reactor. |
bool lf_is_tag_after_stop_tag | ( | environment_t * | env, |
tag_t | tag ) |
Return true if the provided tag is after stop tag.
env | Environment in which we are executing. |
tag | The tag to check against stop tag |
self_base_t * lf_new_reactor | ( | size_t | size | ) |
Allocate memory for a new runtime instance of a reactor.
This records the reactor on the list of reactors to be freed at termination of the program. If you plan to free the reactor before termination of the program, use lf_allocate(size_t, size_t, allocation_record_t**)
with a null last argument instead.
size | The size of the self struct, obtained with sizeof(). |
void lf_print_snapshot | ( | environment_t * | env | ) |
Print a snapshot of the priority queues used during execution (for debugging).
This function implementation will be empty if the NDEBUG macro is defined; that macro is normally defined for release builds.
env | The environment in which we are executing. |
void lf_request_stop | ( | void | ) |
Request a stop to execution as soon as possible.
In a non-federated execution with only a single enclave, this will occur one microstep later than the current tag. In a federated execution or when there is more than one enclave, it will likely occur at a later tag determined by the RTI so that all federates and enclaves stop at the same tag.
void lf_set_present | ( | lf_port_base_t * | port | ) |
Mark the given port's is_present field as true.
port | A pointer to the port struct as an lf_port_base_t* . |
void lf_set_stop_tag | ( | environment_t * | env, |
tag_t | tag ) |
Set the stop tag if it is less than the stop tag of the specified environment.