Module jls.lang.Thread

Represents a thread of execution.

The thread will call a Lua function. The function arguments and return values shall be primitive type: string, number, boolean or nil. The function cannot share variables with the current thread, i.e. must not have upvalues. The package curent values path, cpath and preload are transfered to the thread function.

Class Thread

Thread:new ([fn]) Creates a new Thread.
thread:start ([...]) Starts this Thread.
thread:ended () Returns a promise that resolves once this thread is terminated.
thread:isAlive () Returns true if this thread is alive.
thread:join () Blocks until this thread terminates.


Class Thread

A Thread class.
Thread:new ([fn])
Creates a new Thread.

Parameters:

  • fn function The function to execute in this thread. The function will receive the arguments passed in the start call and may return a single value. If the returned value is a promise then the event loop is called until the promise completes. Errors if any are wrapped into exceptions. (optional)
thread:start ([...])
Starts this Thread. The arguments will be passed to the thread function. If the thread is already running then nothing is done.

Parameters:

  • ... The thread function arguments (optional)

Returns:

    jls.lang.Thread This thread
thread:ended ()
Returns a promise that resolves once this thread is terminated.

Returns:

    jls.lang.Promise A promise that resolves once this thread is terminated
thread:isAlive ()
Returns true if this thread is alive.

Returns:

    boolean true if this thread is alive
thread:join ()
Blocks until this thread terminates.
generated by LDoc 1.4.6