love.thread
Allows you to work with threads.
Threads are separate Lua environments, running in parallel to the main code. As their code runs separately, they can be used to compute complex operations without adversely affecting the frame rate of the main thread. However, as they are separate environments, they cannot access the variables and functions of the main thread, and communication between threads is limited.
All LÖVE objects (userdata) are shared among threads so you’ll only have to send their references across threads. You may run into concurrency issues if you manipulate an object on multiple threads at the same time.
When a Thread is started, it only loads love.data, love.filesystem, and love.thread module. Every other module has to be loaded with require. </i>
Functions
Name | Description | Notes |
---|---|---|
newThread | Creates a new Thread from a filename, string or FileData object containing Lua code | |
newChannel | Creates a new unnamed thread channel | |
getChannel | Creates or retrieves a named thread channel |
Types
Thread
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 </b>
See also:
Name | Description | Notes |
---|---|---|
start | Starts the thread | |
wait | Wait for a thread to finish | |
getError | Retrieves the error string from the thread | |
isRunning | Returns whether the thread is currently running |
Channel
An object which can be used to send and receive data between different threads. </b>
See also:
Name | Description | Notes |
---|---|---|
push | Send a message to a thread Channel | |
supply | Send a message to a thread Channel and wait for a thread to accept it | |
pop | Retrieve the value of a Channel message | |
demand | Wait for and retrieve the value of a Channel message | |
peek | Receive a message from a thread Channel, but leave it in the queue | |
getCount | Retrieves the number of messages in the Channel queue | |
hasRead | Gets whether a pushed value has been popped or otherwise removed from the Channel | |
clear | Clears all the messages in the Channel queue | |
performAtomic | Executes the specified function atomically with respect to this Channel |