Difference between revisions of "love.thread (简体中文)"

(Created page with "{{newin|0.7.0|070|type=module}} Allows you to work with threads. 线程是独立的Lua环境,平行运行于主代码。它们分别运行各自的代码,可以用来进...")
 
m
 
(One intermediate revision by one other user not shown)
Line 1: Line 1:
 
{{newin|[[0.7.0]]|070|type=module}}
 
{{newin|[[0.7.0]]|070|type=module}}
Allows you to work with threads.
+
允许你用模块工作.
  
 
线程是独立的Lua环境,平行运行于主代码。它们分别运行各自的代码,可以用来进行复杂的操作而不影响主线程的帧速率。然而,因为它们是独立的环境下,所以它们不能访问主线程的变量和函数,以及线程间的通信。
 
线程是独立的Lua环境,平行运行于主代码。它们分别运行各自的代码,可以用来进行复杂的操作而不影响主线程的帧速率。然而,因为它们是独立的环境下,所以它们不能访问主线程的变量和函数,以及线程间的通信。
Line 20: Line 20:
 
{{#set:Since=070}}
 
{{#set:Since=070}}
 
== See Also ==
 
== See Also ==
* [[parent::love]]
+
* [[parent::love (简体中文)]]
  
 
== Other Languages ==
 
== Other Languages ==
 
{{i18n|love.thread}}
 
{{i18n|love.thread}}

Latest revision as of 23:01, 27 March 2013

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

允许你用模块工作.

线程是独立的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