This shows you the differences between two versions of the page.
Both sides previous revision Previous revision Next revision | Previous revision Last revision Both sides next revision | ||
api:thread [2017/12/02 10:03] payonel [Event Registration Independence] |
api:thread [2018/02/13 20:57] payonel |
||
---|---|---|---|
Line 26: | Line 26: | ||
* A thread cannot access/remove/interfere with another thread's event registrations. | * A thread cannot access/remove/interfere with another thread's event registrations. | ||
* A pushed event is observed by all running threads on the system. | * A pushed event is observed by all running threads on the system. | ||
+ | * Two separate threads can `event.pull` for the same event, and each thread will observe the event independently. | ||
===== Overview ===== | ===== Overview ===== | ||
Line 279: | Line 280: | ||
- `t:attach([level: number]): boolean, string` | - `t:attach([level: number]): boolean, string` | ||
- | Attaches a thread to a process, conventionally known as a child thread or attached thread. `level` is an optional used to get parent processes, 0 or nil uses the currently running process. When initially created a thread is already attached to the current process. This method returns nil and an error message if `level` refers to a nonexistent process, otherwise it returns truthy. | + | Attaches a thread to a process, conventionally known as a child thread or attached thread. `level` is an optional used to get parent processes, 0 or nil uses the currently running process. When initially created a thread is already attached to the current process. This method returns nil and an error message if `level` refers to a nonexistent process, otherwise it returns truthy. An attached thread blocks its parent process from closing until the thread dies (or is killed, or the parent process aborts). |
- `t:detach(): table, string` | - `t:detach(): table, string` | ||
- | Detaches a thread from its parent if it has one. Returns nil and an error message if no action was taken, otherwise returns self (handy if you want to create and detach a thread in one line). | + | Detaches a thread from its parent if it has one. Returns nil and an error message if no action was taken, otherwise returns self (handy if you want to create and detach a thread in one line). A detached thread will continue to run until the computer is shutdown or rebooted, or the thread dies. |
```lua | ```lua |