reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
lf_token.h
Go to the documentation of this file.
1
38
39#ifndef LF_TOKEN_H
40#define LF_TOKEN_H
41
42#include <stdlib.h> // Defines size_t
43#include <stdbool.h> // Defines bool type
44
45// Forward declarations
46struct environment_t;
47
50
55typedef enum token_freed {
56 NOT_FREED = 0, // Nothing was freed.
57 VALUE_FREED, // The value (payload) was freed.
58 TOKEN_FREED, // The token was freed but not the value.
59 TOKEN_AND_VALUE_FREED // Both were freed
61
64
71typedef struct token_type_t {
75 void (*destructor)(void* value);
77 void* (*copy_constructor)(void* value);
79
111
146
186
187// Forward declaration for self_base_t
189
258
261
271
274
296lf_token_t* lf_new_token(void* port_or_action, void* val, size_t len);
297
316
319
337
353lf_token_t* _lf_new_token(token_type_t* type, void* value, size_t length);
354
368
382void _lf_initialize_template(token_template_t* tmplt, size_t element_size);
383
403
424
432
445
460
468
469#endif /* LF_TOKEN_H */
lf_token_t * lf_new_token(void *port_or_action, void *val, size_t len)
Return a new disassociated token with type matching the specified port or action and containing the s...
lf_token_t * lf_writable_copy(lf_port_base_t *port)
Return a writable copy of the token in the specified template.
token_freed _lf_free_token(lf_token_t *token)
Free the specified token, if appropriate.
lf_token_t * _lf_new_token(token_type_t *type, void *value, size_t length)
Return a new token with the specified type, value, and length.
void _lf_initialize_template(token_template_t *tmplt, size_t element_size)
Initialize the specified template to contain a token that is an.
lf_token_t * _lf_initialize_token(token_template_t *tmplt, size_t length)
Return a token for storing an array of the specified length with new memory allocated (using calloc,...
token_freed _lf_done_using(lf_token_t *token)
Decrement the reference count of the specified token.
lf_token_t * _lf_get_token(token_template_t *tmplt)
Get a token for the specified template.
void _lf_free_token_copies(void)
Free token copies made for mutable inputs.
token_freed
Possible return values for _lf_done_using and _lf_free_token.
Definition lf_token.h:55
void _lf_replace_template_token(token_template_t *tmplt, lf_token_t *newtoken)
Replace the token in the specified template, if there is one, with a new one.
lf_token_t * _lf_initialize_token_with_value(token_template_t *tmplt, void *value, size_t length)
Return a token storing the specified value, which is assumed to be either a scalar (if length is 1) o...
int _lf_count_token_allocations
Counter used to issue a warning if memory is allocated for tokens and never freed.
void _lf_free_all_tokens()
Free all tokens.
@ TOKEN_AND_VALUE_FREED
Definition lf_token.h:59
@ TOKEN_FREED
Definition lf_token.h:58
@ NOT_FREED
Definition lf_token.h:56
@ VALUE_FREED
Definition lf_token.h:57
struct self_base_t self_base_t
Definition lf_token.h:188
Execution environment.
Definition environment.h:52
Base type for ports.
Definition lf_token.h:202
lf_sparse_io_record_t * sparse_record
Record of present channels for sparse I/O.
Definition lf_token.h:229
self_base_t * source_reactor
Pointer to the source reactor.
Definition lf_token.h:256
bool is_present
Indicates whether the port has a present value.
Definition lf_token.h:220
int destination_channel
Channel index for the destination port.
Definition lf_token.h:238
int num_destinations
Number of destination reactors.
Definition lf_token.h:247
token_template_t tmplt
Template containing type and token information.
Definition lf_token.h:211
A record of the subset of channels of a multiport that have present inputs.
Definition lf_token.h:120
size_t capacity
Maximum number of channels that can be tracked before overflow.
Definition lf_token.h:136
int size
Number of present channels or status indicator.
Definition lf_token.h:128
size_t * present_channels
Array of channel indices that have present inputs.
Definition lf_token.h:144
Token type for dynamically allocated arrays and structs sent as messages.
Definition lf_token.h:99
struct lf_token_t * next
Convenience for constructing a temporary list of tokens.
Definition lf_token.h:109
size_t ref_count
The number of times this token is on the event queue.
Definition lf_token.h:107
size_t length
Length of the array or 1 for a non-array.
Definition lf_token.h:103
void * value
Pointer to dynamically allocated memory containing a message.
Definition lf_token.h:101
token_type_t * type
Pointer to the port or action defining the type of the data carried.
Definition lf_token.h:105
The base type for all reactor self structs.
Definition lf_types.h:519
Base type for ports (lf_port_base_t) and actions (trigger_t), which can carry tokens.
Definition lf_token.h:156
lf_token_t * token
Pointer to the current token.
Definition lf_token.h:174
size_t length
Length of the token's value array.
Definition lf_token.h:184
token_type_t type
Type information for the token.
Definition lf_token.h:164
Type information for tokens.
Definition lf_token.h:71
void(* destructor)(void *value)
The destructor or NULL to use the default free().
Definition lf_token.h:75
size_t element_size
Size of the struct or array element.
Definition lf_token.h:73