reactor-c 1.0
C Runtime for Lingua Franca
Loading...
Searching...
No Matches
reaction_macros.h File Reference

Macros providing an API for use in inline reaction bodies. More...

Go to the source code of this file.

Macros

#define lf_add_worker_thread()
 Add a worker thread to the pool of worker threads of the environment invoking this reaction.
#define lf_added_worker_thread_count()
 Return the number of worker threads that have been added to the environment invoking this reaction.
#define lf_async(action, func, ...)
 Invoke a function that may block for a long time without blocking the rest of the program.
#define lf_await(port)
 Suspend this reaction until another reaction of this reactor calls lf_await_resume() on the specified input port.
#define lf_await_resume(port)
 Resume every reaction of this reactor that is suspended in lf_await() on the specified port.
#define lf_reactor_full_name(reactor)
 Return the fully qualified name of the reactor.
#define lf_reactor_name(reactor)
 Return the instance name of the reactor.
#define lf_set(out, val)
 Set the specified output (or input of a contained reactor) to the specified value.
#define lf_set_array(out, val, len)
 Set the specified output (or input of a contained reactor) to the specified array with the given length.
#define lf_set_copy_constructor(out, cpy_ctor)
 Set the copy constructor associated with the specified port.
#define lf_set_destructor(out, dtor)
 Set the destructor associated with the specified port.
#define lf_set_mode(mode)
 Set the next mode of a modal reactor.
#define lf_set_present(out)
 Mark a port present.
#define lf_set_token(out, newtoken)
 Set the specified output (or input of a contained reactor) to the specified token value.
#define lf_tag()
 Return the current tag of the environment invoking this reaction.
#define lf_time_logical()
 Return the current logical time in nanoseconds of the environment invoking this reaction.
#define lf_time_logical_elapsed()
 Return the current logical time of the environment invoking this reaction relative to the start time in nanoseconds.

Detailed Description

Macros providing an API for use in inline reaction bodies.

Author
Edward A. Lee

This set of macros is defined prior to each reaction body and undefined after the reaction body using the set_undef.h header file. If you wish to use these macros in external code, such as that implementing a bodiless reaction, then you can include this header file (and at least reactor.h, plus possibly a few other header files) in your code.

The purpose for these macros is to provide a semblance of polymorphism even though C does not support polymorphism. For example, lf_set(port, value) is a macro where the first argument is a specific port struct and the second type is a value with a type corresponding to the port's type. It is not possible in C to provide a function that can be called with a port struct and a value of any type.

Some of the macros are provided for convenience. For example, the macro can automatically provide common arguments such as the environment and can cast arguments to required base types to suppress warning.

Note for target language developers. This is one way of developing a target language where the C core runtime is adopted. This file is a translation layer that implements Lingua Franca APIs which interact with the internal APIs.