Difference between revisions of "love.thread.getChannel (Français)"

(Voir également)
(Voir également)
 
(One intermediate revision by the same user not shown)
Line 46: Line 46:
 
* [[parent::love.thread (Français)]]
 
* [[parent::love.thread (Français)]]
 
* [[Constructs::Channel (Français)]]
 
* [[Constructs::Channel (Français)]]
[[Category:Functions]]
+
[[Category:Functions (Français)]]
 
{{#set:Description=Crée ou récupère un channel de thread nomée.}}
 
{{#set:Description=Crée ou récupère un channel de thread nomée.}}
 +
{{#set:Since=090}}
  
 
== Autres langues ==
 
== Autres langues ==
 
{{i18n|love.thread.getChannel}}
 
{{i18n|love.thread.getChannel}}

Latest revision as of 12:07, 24 September 2021

Disponible depuis LÖVE 0.9.0
Ce-tte function n'est pas supporté-e par des versions plus anciennes.

Crée et récupère un channel (canal) de thread (fil d'exécution) nommé.

Fonction

Synopsis

channel = love.thread.getChannel( name )

Arguments

string name
Le nom du channel que vous désirez créer ou récupérer.

Retours

Channel channel
L'objet channel associé au nom.

Exemples

Communication entre main/thread

-- main (programme principal)
thread		= love.thread.newThread ( "thread.lua" );
thread:start ();
channel		= {};
channel.a	= love.thread.getChannel ( "a" );
channel.b	= love.thread.getChannel ( "b" );
channel.b:push ( "foo" );

function love.update ( dt )
	local v = channel.a:pop ();
	if v then
		print ( tostring ( v ) );
		channel.b:push ( "foo" );
	end
end

-- thread
channel 	= {};
channel.a	= love.thread.getChannel ( "a" );
channel.b	= love.thread.getChannel ( "b" );

while true do
	local v = channel.b:pop ();
	if v then
		print ( tostring ( v ) );
		channel.a:push ( "bar" );
	end
end

Voir également


Autres langues