Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
Last revision Both sides next revision
api:thread [2017/12/02 09:55]
payonel [Thread API]
api:thread [2018/02/13 20:57]
payonel
Line 21: Line 21:
 ====Event Registration Independence==== ====Event Registration Independence====
  
-A thread maintains an independent set of event registrations. Any event registration made (e.g. listeners or timers) inside a thread belongs to that thread.+A thread maintains an independent set of event registrations; it does not inherit any and it does not share any. Any event registration made (e.g. listeners or timers) inside a thread belongs to that thread.
   * When a thread dies all of its event registrations die with it.   * When a thread dies all of its event registrations die with it.
   * A `suspended` thread ignores events (see `t:status() suspended`)   * A `suspended` thread ignores events (see `t:status() suspended`)
   * 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