Skip to main content

One post tagged with "blocking"

View All Tags

Async and Await in Lingua Franca

· 12 min read
Edward A. Lee
Professor at UC Berkeley
Shulu Li
Graduate Student, UC Berkeley

A reaction in Lingua Franca runs to completion at a single tag; it is "logically instantaneous," meaning that logical time does not elapse during the execution of the reaction. This helps make LF programs deterministic, but it also means that a reaction body cannot wait for anything. If it blocks on a socket, a keyboard, or a slow library call, the whole program stalls. And if it needs a result that some other reactor will produce, the reaction has to end and a second reaction has to pick up where it left off. Two new functions, lf_async and lf_await, remove this restriction in the C and Python targets. A reaction can now suspend in the middle of its body, let logical time advance and other reactions run, and continue later at a well-defined tag, with its local variables intact.