From mboxrd@z Thu Jan 1 00:00:00 1970 Path: eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: Lawrence D'Oliveiro Newsgroups: comp.lang.ada Subject: Parallel Sieve Of Eratosthenes Date: Sun, 30 Jun 2024 08:06:35 -0000 (UTC) Organization: A noiseless patient Spider Message-ID: MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Injection-Date: Sun, 30 Jun 2024 10:06:35 +0200 (CEST) Injection-Info: dont-email.me; posting-host="4341965ad4e2fb75a1b93d496a5627b7"; logging-data="464925"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX18FCMaDlRB+t93flANBSx9P" User-Agent: Pan/0.158 (Avdiivka; ) Cancel-Lock: sha1:If43Ky218kvseUlpfn+SpxDAyjw= Xref: news.eternal-september.org comp.lang.ada:66207 List-Id: with Ada.Text_IO; use Ada; procedure parasieve1 is task type child is entry next_int(i : integer); end child; subtype offspring is child; -- need another name because "child" within child refers to -- current task, not to the type task body child is my_prime : integer; subchild : access offspring; begin accept next_int(i : integer) do my_prime := i; Text_IO.Put_line(integer'image(my_prime)); end next_int; subchild := new offspring; loop accept next_int(i : integer) do if i mod my_prime /= 0 then subchild.next_int(i); end if; end next_int; end loop; end child; first_child : child; i : integer; begin -- parasieve1 i := 1; loop i := i + 1; first_child.next_int(i); end loop; end parasieve1;