thread
Provides threading capabilities.
thread.Channel
(field) thread.Channel: thread.Channel
A channel object.
thread.Thread
(field) thread.Thread: thread.Thread
A thread object.
thread.Channel
A channel object.
__tostring
(method) thread.Channel:__tostring()
-> string
Metamethod that automatically converts a channel to a string representation.
clear
(method) thread.Channel:clear()
Remove all elements from the channel.
first
(method) thread.Channel:first()
-> boolean|string|number|table|nil
Get the first element of the list in the channel.
last
(method) thread.Channel:last()
-> boolean|string|number|table|nil
Get the last element of the list in the channel.
pop
(method) thread.Channel:pop()
Remove the first element of a channel.
push
(method) thread.Channel:push(element: boolean|string|number|table|nil)
-> boolean|nil
2. errorMessage: string
Add a new element to the end of a channel list.
@return errorMessage: string
supply
(method) thread.Channel:supply(element: boolean|string|number|table|nil)
-> boolean|nil
2. errorMessage: string
Add a new element to the end of a channel list and waits for thread to read it.
@return errorMessage: string
wait
(method) thread.Channel:wait()
-> boolean|string|number|table|nil
Wait until the channel has one element and return it.
thread.Thread
A thread object.
__eq
(method) thread.Thread:__eq(thread1: thread.Thread, thread2: thread.Thread)
-> boolean
Metamethod to automatically compare two threads.
@param thread1: thread.Thread — A thread object.
@param thread2: thread.Thread — A thread object.
__tostring
(method) thread.Thread:__tostring()
-> string
Metamethod that automatically converts a thread to a string representation.
get_id
(method) thread.Thread:get_id()
-> integer
Get the id of a thread.
get_name
(method) thread.Thread:get_name()
-> string
Get the name assigned to a thread.
wait
(method) thread.Thread:wait()
-> integer
Wait for a thread to finish and get the return code.
thread.Channel.__tostring
(method) thread.Channel:__tostring()
-> string
Metamethod that automatically converts a channel to a string representation.
thread.Channel.clear
(method) thread.Channel:clear()
Remove all elements from the channel.
thread.Channel.first
(method) thread.Channel:first()
-> boolean|string|number|table|nil
Get the first element of the list in the channel.
thread.Channel.last
(method) thread.Channel:last()
-> boolean|string|number|table|nil
Get the last element of the list in the channel.
thread.Channel.pop
(method) thread.Channel:pop()
Remove the first element of a channel.
thread.Channel.push
(method) thread.Channel:push(element: boolean|string|number|table|nil)
-> boolean|nil
2. errorMessage: string
Add a new element to the end of a channel list.
@return errorMessage: string
thread.Channel.supply
(method) thread.Channel:supply(element: boolean|string|number|table|nil)
-> boolean|nil
2. errorMessage: string
Add a new element to the end of a channel list and waits for thread to read it.
@return errorMessage: string
thread.Channel.wait
(method) thread.Channel:wait()
-> boolean|string|number|table|nil
Wait until the channel has one element and return it.
thread.Thread.__eq
(method) thread.Thread:__eq(thread1: thread.Thread, thread2: thread.Thread)
-> boolean
Metamethod to automatically compare two threads.
@param thread1: thread.Thread — A thread object.
@param thread2: thread.Thread — A thread object.
thread.Thread.__tostring
(method) thread.Thread:__tostring()
-> string
Metamethod that automatically converts a thread to a string representation.
thread.Thread.get_id
(method) thread.Thread:get_id()
-> integer
Get the id of a thread.
thread.Thread.get_name
(method) thread.Thread:get_name()
-> string
Get the name assigned to a thread.
thread.Thread.wait
(method) thread.Thread:wait()
-> integer
Wait for a thread to finish and get the return code.
thread.create
function thread.create(name: string, callback: function, ...boolean|string|number|table|nil)
-> thread.Thread|nil
2. errorMessage: string
Create a new thread and starts it.
@param: boolean|string|number|table|nil — Optional arguments passed to callback
@return: thread.Thread|nil
@return errorMessage: string
thread.get_channel
function thread.get_channel(name: string)
-> thread.Channel|nil
2. errorMessage: string
Creates a new channel or retrieve existing one.
@return: thread.Channel|nil
@return errorMessage: string
thread.get_cpu_count
function thread.get_cpu_count()
-> number
Get the number of CPU cores available.
Returns the total number of logical CPU cores. On CPUs that include technologies such as hyperthreading, the number of logical cores may be more than the number of physical cores.