comp.lang.ada
 help / color / mirror / Atom feed
* Parallel Sieve Of Eratosthenes
@ 2024-06-30  8:06 Lawrence D'Oliveiro
  2024-06-30  8:10 ` Lawrence D'Oliveiro
  0 siblings, 1 reply; 6+ messages in thread
From: Lawrence D'Oliveiro @ 2024-06-30  8:06 UTC (permalink / 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;

^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2024-07-01 21:48 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-06-30  8:06 Parallel Sieve Of Eratosthenes Lawrence D'Oliveiro
2024-06-30  8:10 ` 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

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