love.thread (简体中文)

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

Allows you to work with threads.

线程是独立的Lua环境,平行运行于主代码。它们分别运行各自的代码,可以用来进行复杂的操作而不影响主线程的帧速率。然而,因为它们是独立的环境下,所以它们不能访问主线程的变量和函数,以及线程间的通信。

当一个线程启动时, 它只加载love.thread模块. 所有其他的模块需要用require加载.

O.png love.graphics模块有一些限制,因此它应该只在主线程使用.  


Types

ChannelAn object which can be used to send and receive data between different threads.
ThreadA Thread represents a thread.

Functions

love.thread.getChannelCreates or retrieves a named thread channel.
love.thread.getThreadLook for a thread and get its object.
love.thread.getThreadsGet all threads.
love.thread.newChannelCreates a new unnamed thread channel.
love.thread.newThreadCreates a new Thread from a filename, string or FileData object containing Lua code.


See Also

Other Languages