From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=ham autolearn_force=no version=3.4.4 X-Google-Thread: 103376,bf6902412865b202 X-Google-Attributes: gid103376,public X-Google-Language: ENGLISH,ASCII Path: g2news1.google.com!news3.google.com!news.glorb.com!npeer.de.kpn-eurorings.net!border2.nntp.ams.giganews.com!nntp.giganews.com!feeder.news-service.com!post.news-service.com!news1.surfino.com!not-for-mail Message-Id: <1504092.Iq66gXWrKJ@linux1.krischik.com> From: Martin Krischik Subject: Re: "multithread" Newsgroups: comp.lang.ada Date: Sun, 03 Apr 2005 13:13:56 +0200 References: <4898203.3vGOzBuHlK@linux1.krischik.com> User-Agent: KNode/0.9.0 MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-15 Content-Transfer-Encoding: 8Bit X-Complaints-To: abuse@surfino.com Organization: Surfino Gmbh NNTP-Posting-Host: 83.169.175.19 (83.169.175.19) NNTP-Posting-Date: Sun, 03 Apr 2005 14:00:14 +0200 X-Trace: 90845424fdacef60c0ab618331 Xref: g2news1.google.com comp.lang.ada:10245 Date: 2005-04-03T13:13:56+02:00 List-Id: 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