Yurttas/PL/IL/Ada-95/F/06/p-c/producer consumer 00.adb

From ZCubes Wiki
Jump to navigation Jump to search
 1--
 2-- Copyright(C) 1998
 3-- All Rights Reserved. Salih Yurttas, ZCubes, BitsOfCode Software Systems, Inc..
 4--
 5-- Permission to use, copy, modify, and distribute this
 6-- software and its documentation for EDUCATIONAL purposes
 7-- and without fee is hereby granted provided that this
 8-- copyright notice appears in all copies.
 9--
10 
11-- date   : January 1, 1998.
12-- author : Salih Yurttas.
13
14-- producer_consumer_00.adb
15
16
17with Ada.Text_IO;
18use Ada.Text_IO;
19
20procedure Producer_Consumer_00 is
21
22  type Unit is new Integer;
23
24  package Int_IO is new Integer_IO(Unit);
25  use Int_IO;
26
27  task Consumer is
28    entry P(A : in Unit);
29  end Consumer;
30
31  task body Consumer is
32    Item : Unit;
33  begin
34    loop
35      accept P(A : in Unit) do
36        Item := A;
37      end P;
38      Put(Item);
39      New_Line;
40    end loop;
41  end Consumer;
42
43  task Producer;
44
45  task body Producer is
46    Item : Unit;
47  begin
48    loop
49      Item := 9;
50      Consumer.P(Item);
51    end loop;
52  end Producer;
53
54begin
55
56  null;
57
58end Producer_Consumer_00;