Skip to main content

Thread

Description:

  A Thread is a chunk of code that can run in parallel with other threads. Data can be sent between different threads with Channel objects.

release

Type: Function.

Description:

  Destroys the object's Lua reference. The object will be completely deleted if it's not referenced by any other LÖVE object or thread. This method can be used to immediately clean up resources without waiting for Lua's garbage collector.

Signature:

release: function(self: Thread): boolean

Returns:

Return TypeDescription
booleanTrue if the object was released by this call, false if it had been previously released.

type

Type: Function.

Description:

  Gets the type of the object as a string.

Signature:

type: function(self: Thread): string

Returns:

Return TypeDescription
stringThe type as a string.

Of

Type: Function.

Description:

  Checks whether an object is of a certain type. If the object has the type with the specified name in its hierarchy, this function will return true.

Signature:

typeOf: function(self: Thread, type_name: string): boolean

Parameters:

ParameterTypeDescription
type_namestringThe name of the type to check for.

Returns:

Return TypeDescription
booleanTrue if the object is of the specified type, false otherwise.

start

Type: Function.

Description:

  Starts the thread. Beginning with version 0.9.0, threads can be restarted after they have completed their execution. Overload details:

  1. Arguments passed to Thread:start are accessible in the thread's main file via '''...''' (the vararg expression.)

Signature:

start: function(self: Thread, args: any...): boolean

Parameters:

ParameterTypeDescription
argsany...A string, number, boolean, LÖVE object, or simple table.

wait

Type: Function.

Description:

  Wait for a thread to finish. This call will block until the thread finishes.

Signature:

wait: function(self: Thread)

getError

Type: Function.

Description:

  Retrieves the error string from the thread if it produced an error.

Signature:

getError: function(self: Thread): string | nil

Returns:

Return TypeDescription
string or nilThe error message, or nil if the Thread has not caused an error.

isRunning

Type: Function.

Description:

  Returns whether the thread is currently running. Threads which are not running can be (re)started with Thread:start.

Signature:

isRunning: function(self: Thread): boolean

Returns:

Return TypeDescription
booleanTrue if the thread is running, false otherwise.