isparallel

Checks if the current thread is running in parallel.

Syntax

isparallel() -> boolean

Returns

TypeDescription
booleanTrue 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")
end

Use 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.IsActorState when you need to test state ownership instead