love.thread

Available since LÖVE 0.7.0
This module is not supported in earlier versions.

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 LOVE 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 the love.thread module. Every other module has to be loaded with require.

The love.graphics and love.window modules have several restrictions and therefore can only be used in the main thread.

Unless you define the love.threaderror callback or call Thread:getError you won't see any errors your thread code throws.

Types

Channel An object which can be used to send and receive data between different threads. 0.9.0
Thread A Thread represents a thread. 0.7.0

Functions

love.thread.getChannel Creates or retrieves a named thread channel. 0.9.0
love.thread.getThread Look for a thread and get its object. 0.7.0 0.9.0
love.thread.getThreads Get all threads. 0.7.0 0.9.0
love.thread.newChannel Creates a new unnamed thread channel. 0.9.0
love.thread.newThread Creates a new Thread from a Lua file or FileData object. 0.7.0


Examples

For 0.9.0: http://love2d.org/forums/viewtopic.php?f=4&t=76670

See Also

Thread:getName
  • References/Game Development/LÖVE/love.thread/Thread

Thread:getName Available since LÖVE 0.7.0 and removed in LÖVE 0.9.0 This function is not supported in earlier or later versions. Get the name

2025-01-10 15:47:30
love.thread.getChannel
  • References/Game Development/LÖVE/love.thread

love.thread.getChannel Available since LÖVE 0.9.0 This function is not supported in earlier versions. Creates or retrieves a named thread channel

2025-01-10 15:47:30
Thread:wait
  • References/Game Development/LÖVE/love.thread/Thread

Thread:wait Available since LÖVE 0.7.0 This function is not supported in earlier versions. Wait for a thread to finish. This call will block

2025-01-10 15:47:30
Channel:getCount
  • References/Game Development/LÖVE/love.thread/Channel

Channel:getCount Available since LÖVE 0.9.0 This function is not supported in earlier versions. Retrieves the number of messages in the thread

2025-01-10 15:47:30
Channel:demand
  • References/Game Development/LÖVE/love.thread/Channel

Channel:demand Available since LÖVE 0.9.0 This function is not supported in earlier versions. Retrieves the value of a Channel message and removes

2025-01-10 15:47:30
Thread:receive
  • References/Game Development/LÖVE/love.thread/Thread

Thread:receive Available since LÖVE 0.7.0 and removed in LÖVE 0.8.0 It has been renamed to

2025-01-10 15:47:30
Thread:demand
  • References/Game Development/LÖVE/love.thread/Thread

Thread:demand Available since LÖVE 0.7.0 and removed in LÖVE 0.9.0 It has been moved to the

2025-01-10 15:47:30
Channel:supply
  • References/Game Development/LÖVE/love.thread/Channel

Channel:supply Available since LÖVE 0.9.0 This function is not supported in earlier versions. Send a message to the thread Channel and wait

2025-01-10 15:47:30
love.thread.newThread
  • References/Game Development/LÖVE/love.thread

love.thread.newThread Available since LÖVE 0.7.0 This function is not supported in earlier versions. Creates a new Thread from a Lua file or

2025-01-10 15:47:30
Channel:peek
  • References/Game Development/LÖVE/love.thread/Channel

Channel:peek Available since LÖVE 0.9.0 This function is not supported in earlier versions. Retrieves the value of a Channel message, but leaves

2025-01-10 15:47:30