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 20 of file Runtime.cpp.

21{
22 std::lock_guard<std::mutex> guard(g_mutex);
23
24 if (g_instance) {
25 LILA_WARN(Lila::Emitter::SYSTEM,
26 "start_lila: already running on port " + std::to_string(g_port));
27 return false;
28 }
29
30 auto instance = std::make_unique<Lila::Lila>();
31
32 if (!instance->initialize(Lila::OperationMode::Both, static_cast<int>(port), true)) {
33 LILA_ERROR(Lila::Emitter::SYSTEM,
34 "start_lila: initialization failed: " + instance->get_last_error());
35 return false;
36 }
37
38 g_instance = std::move(instance);
39 g_port = port;
40
41#ifdef MAYAFLUX_PLATFORM_WINDOWS
42 g_instance->set_main_thread_id(static_cast<uint32_t>(GetCurrentThreadId()));
43#endif
44
45 LILA_INFO(Lila::Emitter::SYSTEM,
46 "start_lila: running on port " + std::to_string(port));
47 return true;
48}
#define LILA_WARN(emitter, msg)
#define LILA_ERROR(emitter, msg)
#define LILA_INFO(emitter, msg)

References LILA_ERROR, LILA_INFO, and LILA_WARN.