The Midio Engine
Overview
Midio compiled to bytecode, meaning that before the node graph is executed, it is compiled to a list of instructions, which is then executed by the [Midio VM](#The Midio VM). This makes the code run a lot faster than it would if we had to interpret the node graph during execution.
The Midio engine is a virtual machine that executes the bytecode produced by the compiler. It is responsible for hooking up all the native functionality that the code depends on, like all external functions, and services.
The bytecode is executed in Midio processes, of which several can run concurrently, executing different flows.
Processes
A process represents an isolated environment for bytecode to be executed in. It contains its own call stack, and its own memory heap, and is not able to affect other processes directly.
Processes are created by supplying it a module to run. It can then be handed to the scheduler, which will eventually schedule it for execution.
A process can be in one of the following states:
Runnable - The process is ready to be scheduled by the scheduler
DoneAndWaitingForCleanup - The process is done executing, and is waiting for the engine to clean up its resources, like heap and stack.
Error - The process has experienced an error, and is waiting for cleanup.
Paused - The process is paused for debugging purposes
Stepping - The process is in debugger state, and the middle of performing a single. The difference from being Runnable is that the process will enter the Paused state as soon as it hits an instruction corresponding to a node, like a
CallFunction
instruction.
Services
Services are not something the user directly interfaces with, but are accessed through various functions in the standard library.
Services are components that provide various capabilities to your programs, such as offering an HTTP server, scheduling flows at specific intervals, and more. These services are shared between processes and are instantiated automatically when a node that requires the service is used. This process is entirely transparent to the user, and the way you interact with services is through funtions whose implementation happen to use them.
Currently, you cannot create your own service, but this will eventually be possible.
Some existing services include:
HttpServer: Enables the creation of HTTP APIs. Some functions that use this service include
HttpEndpoint
andHttpResponse
.Scheduler: Allows scheduling of flows to run at specific intervals. The
Timer
event uses this sevices.Testing: Offers a way for tests to report their results. Some nodes using this service includes the
Test
event and the various assertion functions, like:AssertEqual
,AssertTrue
andAssertFalse
.Ephemeral Store: Provides an in-memory key-value store (non-persistent) for storing data between various flow executions. This service is accessed through the functions in the
EphemeralStore
module.
Last updated
Was this helpful?