annotate gcc/ada/libgnarl/g-boubuf.ads @ 131:84e7813d76e9

gcc-8.2
author mir3636
date Thu, 25 Oct 2018 07:37:49 +0900
parents 04ced10e8804
children 1830386684a0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
111
kono
parents:
diff changeset
1 ------------------------------------------------------------------------------
kono
parents:
diff changeset
2 -- --
kono
parents:
diff changeset
3 -- GNAT LIBRARY COMPONENTS --
kono
parents:
diff changeset
4 -- --
kono
parents:
diff changeset
5 -- G N A T . B O U N D E D _ B U F F E R S --
kono
parents:
diff changeset
6 -- --
kono
parents:
diff changeset
7 -- S p e c --
kono
parents:
diff changeset
8 -- --
131
84e7813d76e9 gcc-8.2
mir3636
parents: 111
diff changeset
9 -- Copyright (C) 2003-2018, AdaCore --
111
kono
parents:
diff changeset
10 -- --
kono
parents:
diff changeset
11 -- GNAT is free software; you can redistribute it and/or modify it under --
kono
parents:
diff changeset
12 -- terms of the GNU General Public License as published by the Free Soft- --
kono
parents:
diff changeset
13 -- ware Foundation; either version 3, or (at your option) any later ver- --
kono
parents:
diff changeset
14 -- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
kono
parents:
diff changeset
15 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
kono
parents:
diff changeset
16 -- or FITNESS FOR A PARTICULAR PURPOSE. --
kono
parents:
diff changeset
17 -- --
kono
parents:
diff changeset
18 -- As a special exception under Section 7 of GPL version 3, you are granted --
kono
parents:
diff changeset
19 -- additional permissions described in the GCC Runtime Library Exception, --
kono
parents:
diff changeset
20 -- version 3.1, as published by the Free Software Foundation. --
kono
parents:
diff changeset
21 -- --
kono
parents:
diff changeset
22 -- You should have received a copy of the GNU General Public License and --
kono
parents:
diff changeset
23 -- a copy of the GCC Runtime Library Exception along with this program; --
kono
parents:
diff changeset
24 -- see the files COPYING3 and COPYING.RUNTIME respectively. If not, see --
kono
parents:
diff changeset
25 -- <http://www.gnu.org/licenses/>. --
kono
parents:
diff changeset
26 -- --
kono
parents:
diff changeset
27 -- GNAT was originally developed by the GNAT team at New York University. --
kono
parents:
diff changeset
28 -- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
kono
parents:
diff changeset
29 -- --
kono
parents:
diff changeset
30 ------------------------------------------------------------------------------
kono
parents:
diff changeset
31
kono
parents:
diff changeset
32 -- This package provides a thread-safe generic bounded buffer abstraction.
kono
parents:
diff changeset
33 -- Instances are useful directly or as parts of the implementations of other
kono
parents:
diff changeset
34 -- abstractions, such as mailboxes.
kono
parents:
diff changeset
35
kono
parents:
diff changeset
36 -- Bounded_Buffer is declared explicitly as a protected type, rather than as
kono
parents:
diff changeset
37 -- a simple limited private type completed as a protected type, so that
kono
parents:
diff changeset
38 -- clients may make calls accordingly (i.e., conditional/timed entry calls).
kono
parents:
diff changeset
39
kono
parents:
diff changeset
40 with System;
kono
parents:
diff changeset
41
kono
parents:
diff changeset
42 generic
kono
parents:
diff changeset
43 type Element is private;
kono
parents:
diff changeset
44 -- The type of the values contained within buffer objects
kono
parents:
diff changeset
45
kono
parents:
diff changeset
46 package GNAT.Bounded_Buffers is
kono
parents:
diff changeset
47 pragma Pure;
kono
parents:
diff changeset
48
kono
parents:
diff changeset
49 type Content is array (Positive range <>) of Element;
kono
parents:
diff changeset
50 -- Content is an internal artefact that cannot be hidden because protected
kono
parents:
diff changeset
51 -- types cannot contain type declarations.
kono
parents:
diff changeset
52
kono
parents:
diff changeset
53 Default_Ceiling : constant System.Priority := System.Default_Priority;
kono
parents:
diff changeset
54 -- A convenience value for the Ceiling discriminant
kono
parents:
diff changeset
55
kono
parents:
diff changeset
56 protected type Bounded_Buffer
kono
parents:
diff changeset
57 (Capacity : Positive;
kono
parents:
diff changeset
58 -- Objects of type Bounded_Buffer specify the maximum number of Element
kono
parents:
diff changeset
59 -- values they can hold via the discriminant Capacity.
kono
parents:
diff changeset
60
kono
parents:
diff changeset
61 Ceiling : System.Priority)
kono
parents:
diff changeset
62 -- Users must specify the ceiling priority for the object. If the
kono
parents:
diff changeset
63 -- Real-Time Systems Annex is not in use this value is not important.
kono
parents:
diff changeset
64 is
kono
parents:
diff changeset
65 pragma Priority (Ceiling);
kono
parents:
diff changeset
66
kono
parents:
diff changeset
67 entry Insert (Item : Element);
kono
parents:
diff changeset
68 -- Insert Item into the buffer, blocks caller until space is available
kono
parents:
diff changeset
69
kono
parents:
diff changeset
70 entry Remove (Item : out Element);
kono
parents:
diff changeset
71 -- Remove next available Element from buffer. Blocks caller until an
kono
parents:
diff changeset
72 -- Element is available.
kono
parents:
diff changeset
73
kono
parents:
diff changeset
74 function Empty return Boolean;
kono
parents:
diff changeset
75 -- Returns whether the instance contains any Elements.
kono
parents:
diff changeset
76 -- Note: State may change immediately after call returns.
kono
parents:
diff changeset
77
kono
parents:
diff changeset
78 function Full return Boolean;
kono
parents:
diff changeset
79 -- Returns whether any space remains within the instance.
kono
parents:
diff changeset
80 -- Note: State may change immediately after call returns.
kono
parents:
diff changeset
81
kono
parents:
diff changeset
82 function Extent return Natural;
kono
parents:
diff changeset
83 -- Returns the number of Element values currently held
kono
parents:
diff changeset
84 -- within the instance.
kono
parents:
diff changeset
85 -- Note: State may change immediately after call returns.
kono
parents:
diff changeset
86
kono
parents:
diff changeset
87 private
kono
parents:
diff changeset
88 Values : Content (1 .. Capacity);
kono
parents:
diff changeset
89 -- The container for the values held by the buffer instance
kono
parents:
diff changeset
90
kono
parents:
diff changeset
91 Next_In : Positive := 1;
kono
parents:
diff changeset
92 -- The index of the next Element inserted. Wraps around
kono
parents:
diff changeset
93
kono
parents:
diff changeset
94 Next_Out : Positive := 1;
kono
parents:
diff changeset
95 -- The index of the next Element removed. Wraps around
kono
parents:
diff changeset
96
kono
parents:
diff changeset
97 Count : Natural := 0;
kono
parents:
diff changeset
98 -- The number of Elements currently held
kono
parents:
diff changeset
99 end Bounded_Buffer;
kono
parents:
diff changeset
100
kono
parents:
diff changeset
101 end GNAT.Bounded_Buffers;