Future of Lambda (Expression) — skLambda
Addon: skLambda · Category: Expression · Since: 1.3.0
Syntax
[a] future of (calling|running|invoking) lambda %object% [with %-objects%]Description
Starts a lambda off the main thread immediately and returns a future for its result. WARNING: the lambda runs on a background thread, so its body MUST be thread-safe: pure computation or I/O only, with no Bukkit API (no blocks, entities, inventories, players, or other server state). Touching the server from a background thread will throw or corrupt state. Arguments are evaluated on the main thread before the lambda starts. Await the result with `wait for %future%`, which suspends the trigger without blocking the server.
Examples
set {_hash} to lambda (text: string) -> string:
return sha256 of {_text}
set {_f} to future of calling lambda {_hash} with "payload"
wait for {_f} for at most 5 seconds:
send "hash: %result of {_f}%"