getactorfromthread(thread) / getactorfromstate(thread)
Returns the Actor a thread runs on, including task.spawn children.
Syntax
getactorfromthread(thread: thread) -> Instance?
Parameters
| Parameter | Type | Description |
|---|---|---|
thread | thread | Thread or Actor instance. |
Returns
| Type | Description |
|---|---|
Instance? | The owning Actor, or nil for ordinary threads. |
Description
Returns the Actor instance passed as the argument, or the actor bound to a thread's extra space.
Logic change: when the thread's own extra space has no actor (typical for task.spawn/task.defer children inside an actor), the implementation falls back to matching the thread's shared-context pointer against actor-bound threads and returns that Actor.
Example
runonactor(actor, [[Actor:SetAttribute("Matched", getactorfromthread(coroutine.running()) == Actor)]])
Notes
- Returns nil for threads outside actors.