Module irccd.thread

Threads.


Note: Threads are very experimental and not widely tested yet.

This API provides functions to create individual threads within plugins.

Functions

new (func, ...) Create a new thread.

Class Thread

Thread:join () Wait the thread to finish.
Thread:detach () Permit the detached execution of a thread.

Thread metamethods

Thread:__gc () Thread destructor.
Thread:__tostring () Convert thread to string.


Functions

new (func, ...)
Create a new thread. Use the function as the thread function. You can pass any parameter you like to the thread just after the function itself.


Note: userdata and functions are not supported as parameters.

You may discard the return value, the thread will automatically be deleted when its execution has finished

Parameters:

  • func the thread function
  • ... the arguments to pass to the thread function

Returns:

    a Thread object

Class Thread

Thread:join ()
Wait the thread to finish. This function blocks until the thread finishes its execution. Be careful using this function as it may block other plugins.

Returns:

  1. true on success or nil
  2. an error message
Thread:detach ()
Permit the detached execution of a thread. You usually do not need to call this function, the __gc function automatically do it.


Note: it's not a good practice to detach threads.

Returns:

  1. true on success or nil
  2. an error message

Thread metamethods

The metamethods available for object Thread.
Thread:__gc ()
Thread destructor. Destructor for a thread, if the thread has not been joined or detached, it is detached by this function.
Thread:__tostring ()
Convert thread to string.

Returns:

    the string
generated by LDoc 1.4.0