self:pause
Shared
Yields the currently running thread, suspending execution until it is resumed
Syntax
local status = self:pause()This function must be called from within a running thread. It cannot be used outside a thread context, while already sleeping, or while awaiting a util.promise.
- Available — execution is suspended at the call site and resumes from that point when
self:resumeis called. - Outside a thread — the call is a no-op and returns
false. - Sleeping or awaiting — the call is ignored and returns
false.
Parameters
| No parameters are accepted by this function |
|---|
Returns
| Type | Name | Description |
|---|---|---|
bool | status | true on successful execution, false otherwise |
Examples
local entity = util.thread.create(function(self)
core.engine.print("info", "Before pause")
self:pause()
core.engine.print("info", "After resume")
end)
entity:resume()
entity:resume()