MayaFlux 0.4.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ start_lila()

MAYAFLUX_HOST_API bool MayaFlux::Host::Live::start_lila ( uint16_t  port = 9090)

Start a Lila interpreter and TCP server inside this process.

Constructs a Lila instance and initializes it in OperationMode::Both. The interpreter skips loading MayaFluxLib because the host process already has it resident in the symbol table.

Only one Lila instance is permitted per process. Subsequent calls while one is already running return false and log a warning.

JIT'd code evaluated through this session can call any MayaFlux symbol visible in the process symbol table. Objects constructed with shorter lifetimes than the host should use MayaFlux::store() or MayaFlux::make_persistent() to survive declaration-group scoping.

Parameters
portTCP port for the Lila server to listen on.
Returns
true on successful start, false otherwise.

Definition at line 24 of file Runtime.cpp.

25{
26 std::lock_guard<std::mutex> guard(g_mutex);
27
28 if (g_instance) {
29 LILA_WARN(Lila::Emitter::SYSTEM,
30 "start_lila: already running on port " + std::to_string(g_port));
31 return false;
32 }
33
34 auto instance = std::make_unique<Lila::Lila>();
35
36 for (const auto& p : g_pending_include_paths)
37 instance->add_include_path(p);
38 g_pending_include_paths.clear();
39
40 for (const auto& f : g_pending_compile_flags)
41 instance->add_compile_flag(f);
42 g_pending_compile_flags.clear();
43
44 if (!instance->initialize(Lila::OperationMode::Both, static_cast<int>(port), true)) {
45 LILA_ERROR(Lila::Emitter::SYSTEM,
46 "start_lila: initialization failed: " + instance->get_last_error());
47 return false;
48 }
49
50 for (const auto& lib : g_pending_libraries)
51 instance->load_library(lib);
52 g_pending_libraries.clear();
53
54 for (const auto& code : g_pending_evals)
55 instance->eval(code);
56 g_pending_evals.clear();
57
58 g_instance = std::move(instance);
59 g_port = port;
60
61 LILA_INFO(Lila::Emitter::SYSTEM,
62 "start_lila: running on port " + std::to_string(port));
63 return true;
64}
#define LILA_WARN(emitter, msg)
#define LILA_ERROR(emitter, msg)
#define LILA_INFO(emitter, msg)

References LILA_ERROR, LILA_INFO, and LILA_WARN.