isparallel
Checks if the current thread is running in parallel.
Syntax
isparallel() -> booleanReturns
| Type | Description |
|---|---|
boolean | True if running in a parallel context |
Description
isparallel returns whether the current thread is running in parallel.
Example
if isparallel() then
print("Running in parallel!")
-- Safe to do parallel-safe operations
else
print("Running on main thread")
endUse in Actor
local actor = assert(getactors()[1], "No active actor state")
run_on_actor(actor, [[
-- Reports the state at the moment this code runs; being in an Actor does
-- not guarantee true.
print("Is parallel:", isparallel())
]])
print("Is parallel:", isparallel())Notes
- The result reflects the current execution phase
- Use
LuaStateProxy.IsActorStatewhen you need to test state ownership instead
Related Functions
run_on_actor- Run code on an actorgetactors- Get active Actors