nvim_runtime_lua

uv.luv_thread_t

supers: userdata

Methods8

function luv_thread_t.equal(other_thread: uv.luv_thread_t) -> boolean

Returns a boolean indicating whether two threads are the same. This function is equivalent to the __eq metamethod.

function luv_thread_t.setaffinity(affinity: {integer, boolean}, get_old_affinity: nil | boolean) -> (affinity {integer, boolean} | nil, err nil | string, err_name uv.error_name | nil)

Sets the specified thread's affinity setting.

affinity must be a table where each of the keys are a CPU number and the values are booleans that represent whether the thread should be eligible to run on that CPU. If the length of the affinity table is not greater than or equal to uv.cpumask_size(), any CPU numbers missing from the table will have their affinity set to false. If setting the affinity of more than uv.cpumask_size() CPUs is desired, affinity must be an array-like table with no gaps, since #affinity will be used as the cpumask_size if it is greater than uv.cpumask_size().

If get_old_affinity is true, the previous affinity settings for the thread will be returned. Otherwise, true is returned after a successful call.

Note: Thread affinity setting is not atomic on Windows. Unsupported on macOS.

function luv_thread_t.getaffinity(mask_size: nil | integer) -> (affinity {integer, boolean} | nil, err nil | string, err_name uv.error_name | nil)

Gets the specified thread's affinity setting.

If mask_size is provided, it must be greater than or equal to uv.cpumask_size(). If the mask_size parameter is omitted, then the return of uv.cpumask_size() will be used. Returns an array-like table where each of the keys correspond to a CPU number and the values are booleans that represent whether the thread is eligible to run on that CPU.

Note: Thread affinity getting is not atomic on Windows. Unsupported on macOS.

function luv_thread_t.setpriority(priority: integer) -> (success nil | boolean, err nil | string, err_name uv.error_name | nil)

Sets the specified thread's scheduling priority setting. It requires elevated privilege to set specific priorities on some platforms.

The priority can be set to the following constants.

  • uv.constants.THREADPRIORITYHIGHEST
  • uv.constants.THREADPRIORITYABOVE_NORMAL
  • uv.constants.THREADPRIORITYNORMAL
  • uv.constants.THREADPRIORITYBELOW_NORMAL
  • uv.constants.THREADPRIORITYLOWEST
function luv_thread_t.getpriority() -> (priority nil | integer, err nil | string, err_name uv.error_name | nil)

Gets the thread's priority setting.

Retrieves the scheduling priority of the specified thread. The returned priority value is platform dependent.

For Linux, when schedule policy is SCHED_OTHER (default), priority is 0.

function luv_thread_t.join() -> (success nil | boolean, err nil | string, err_name uv.error_name | nil)

Waits for the thread to finish executing its entry function.

function luv_thread_t.detach() -> (success nil | boolean, err nil | string, err_name uv.error_name | nil)

Detaches a thread. Detached threads automatically release their resources upon termination, eliminating the need for the application to call uv.thread_join.

function luv_thread_t.getname() -> (name nil | string, err nil | string, err_name uv.error_name | nil)

Gets the name of the thread specified by thread.