comp.lang.ada
 help / color / mirror / Atom feed
From: Lawrence D'Oliveiro <ldo@nz.invalid>
Subject: Parallel Sieve Of Eratosthenes
Date: Sun, 30 Jun 2024 08:06:35 -0000 (UTC)	[thread overview]
Message-ID: <v5r3ma$e60t$1@dont-email.me> (raw)

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;

             reply	other threads:[~2024-06-30  8:06 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-06-30  8:06 Lawrence D'Oliveiro [this message]
2024-06-30  8:10 ` Parallel Sieve Of Eratosthenes Lawrence D'Oliveiro
2024-06-30 16:36   ` J-P. Rosen
2024-07-01  0:02     ` Lawrence D'Oliveiro
2024-07-01  9:17       ` J-P. Rosen
2024-07-01 21:48         ` Lawrence D'Oliveiro
replies disabled

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