Expand description
Thread-isolated Lua VM with cancellation for mlua.
mlua-isle runs a Lua VM on a dedicated thread and communicates via
channels. This solves two fundamental problems with mlua:
-
Luais!Send— it cannot cross thread boundaries. By confining the VM to one thread and sending requests over a channel, callers on any thread (UI, async runtime, etc.) can interact with Lua withoutSendissues. -
Cancellation — long-running Lua code (including blocking Rust callbacks like HTTP calls) can be interrupted via a cancel token that triggers both a Lua debug hook and a caller-side signal.
§Architecture
┌─────────────────┐ mpsc ┌──────────────────┐
│ caller thread │─────────►│ Lua thread │
│ (UI / async) │ │ (mlua confined) │
│ │◄─────────│ │
│ Isle handle │ oneshot │ Lua VM + hook │
└─────────────────┘ └──────────────────┘§Example
use mlua_isle::Isle;
let isle = Isle::spawn(|lua| {
lua.globals().set("greeting", "hello")?;
Ok(())
}).unwrap();
let result: String = isle.eval("return greeting").unwrap();
assert_eq!(result, "hello");
isle.shutdown().unwrap();Structs§
- Cancel
Token - Cancellation signal shared between caller and Lua thread.
- Isle
- Handle to a thread-isolated Lua VM.
- Task
- Handle to a pending Lua operation.
Enums§
- Isle
Error - Errors returned by Isle operations.