-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathpragmarc-concurrent_pipeline.adb
83 lines (73 loc) · 2.48 KB
/
pragmarc-concurrent_pipeline.adb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
-- PragmAda Reusable Component (PragmARC)
-- Copyright (C) 2020 by PragmAda Software Engineering. All rights reserved.
-- Released under the terms of the BSD 3-Clause license; see https://opensource.org/licenses
-- **************************************************************************
--
-- History:
-- 2020 Nov 01 J. Carter V2.0--Initial Ada-12 version
----------------------------------------------------------------------------
-- 2016 Sep 15 J. Carter V1.0--Initial release
--
with Ada.Containers.Indefinite_Holders;
package body PragmARC.Concurrent_Pipeline is
package body Transformers is
task Transformer is
entry Put (Item : in Input);
end Transformer;
procedure Put (Item : in Input) is
-- Empty
begin -- Put
Transformer.Put (Item => Item);
end Put;
task body Transformer is
package Holder is new Ada.Containers.Indefinite_Holders (Element_Type => Input);
Value : Holder.Holder;
begin -- Transformer
Forever : loop
select
accept Put (Item : in Input) do
Value.Replace_Element (New_Item => Item);
end Put;
Handle_Error : begin
Put (Item => Transform (Value.Element) );
exception -- Handle_Error
when others =>
null;
end Handle_Error;
or
terminate;
end select;
end loop Forever;
end Transformer;
end Transformers;
package body Sinks is
task Processor is
entry Put (Item : in Input);
end Processor;
procedure Put (Item : in Input) is
-- Empty
begin -- Put
Processor.Put (Item => Item);
end Put;
task body Processor is
package Holder is new Ada.Containers.Indefinite_Holders (Element_Type => Input);
Value : Holder.Holder;
begin -- Processor
Forever : loop
select
accept Put (Item : in Input) do
Value.Replace_Element (New_Item => Item);
end Put;
Handle_Error : begin
Process (Item => Value.Element);
exception -- Handle_Error
when others =>
null;
end Handle_Error;
or
terminate;
end select;
end loop Forever;
end Processor;
end Sinks;
end PragmARC.Concurrent_Pipeline;