comp.lang.ada
 help / color / mirror / Atom feed
From: Martin Krischik <krischik@users.sourceforge.net>
Subject: Re: "multithread"
Date: Sun, 03 Apr 2005 13:13:56 +0200
Date: 2005-04-03T13:13:56+02:00	[thread overview]
Message-ID: <1504092.Iq66gXWrKJ@linux1.krischik.com> (raw)
In-Reply-To: pan.2005.04.03.09.07.28.432842@nospam.a2lf.org

Jean-Baptiste CAMPESATO wrote:

> Le Sun, 03 Apr 2005 10:40:10 +0200, Martin Krischik a ᅵcritᅵ:
> 
>> Jean-Baptiste CAMPESATO wrote:
>> 
>>> Hello,
>>> I want to create a function wich can called "several times at the same
>>> time", MultiThread.
>> 
>> Apart from the tips you allready got: If you want Go to be called more
>> then once "at the same time" you will need a "task type" instead of a
>> simple task.
>> 
>> 
>> 
>>> I found task and i tested :
>>> In ADS :
>>>         -- Tache pour le traitement du client
>>>         task Traitement is
>>>                 entry Go(Client:Socket_Type);
>>>         end Traitement;
>> 
>>          task type Traitement is
>>                  entry Go(Client:Socket_Type);
>>          end Traitement;
>> 
>>        type Traitement_Access is access Traitement ;
>> 
>>> -----------------------------------------------
>>> In ADB :
>>>         task body Traitement is
>>>         begin
>>>                 accept Go(Client:Socket_Type) do
>>>                         put_line("Tache.");
>>>                         Close_Socket(Client);
>>>                 end Go;
>>>         end Traitement;
>>> ------------------------------------------------
>>> In the loop wich call Traitement:
>>>                 loop
>>>                         -- On accepte le client
>>>                         Accept_Socket (Server, Client, Address);
>> 
>> Inside the loop you would need to create a new task from the task type:
>> 
>>      declare
>>           New_Traitement  : Traitement_Access := new Traitement
>>      begin
>>           -- Et on crᅵᅵ un thread pour lui
>>           New_Traitement.Go(Client);
>>     end;
>>   
>>>                 end loop;
>> 
>> And now it get's tricky - because this is the one point where garbage
>> collection is really missing. Garbage collection is only an optional
>> feature and standart Ada compilers haven't got it.
>> 
>> But you never know when the task is finished so you never know when to
>> free the memory allocated for the task.
>> 
>> Martin
> 
> Ok thanks.
> But the answer of Jim Rogers works for me :/.
> It's strange.

Prehaps "Go" executes so fast that you never notice the difference ;-).

Martin
-- 
mailto://krischik@users.sourceforge.net
Ada programming at: http://ada.krischik.com




  reply	other threads:[~2005-04-03 11:13 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-04-02 22:37 "multithread" Jean-Baptiste CAMPESATO
2005-04-03  1:34 ` "multithread" Jim Rogers
2005-04-03  7:30   ` "multithread" Jean-Baptiste CAMPESATO
2005-04-03  7:12 ` "multithread" Martin Dowie
2005-04-03  8:40 ` "multithread" Martin Krischik
2005-04-03  9:07   ` "multithread" Jean-Baptiste CAMPESATO
2005-04-03 11:13     ` Martin Krischik [this message]
2005-04-03 12:14       ` "multithread" Jean-Baptiste CAMPESATO
2005-04-03 13:42         ` "multithread" Adrian Knoth
2005-04-03 13:24       ` "multithread" Jean-Baptiste CAMPESATO
2005-04-03 22:27 ` "multithread" Jeffrey Carter
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox