1 |
281 |
jeremybenn |
------------------------------------------------------------------------------
|
2 |
|
|
-- --
|
3 |
|
|
-- GNAT LIBRARY COMPONENTS --
|
4 |
|
|
-- --
|
5 |
|
|
-- G N A T . B O U N D E D _ M A I L B O X E S --
|
6 |
|
|
-- --
|
7 |
|
|
-- S p e c --
|
8 |
|
|
-- --
|
9 |
|
|
-- Copyright (C) 2003-2006, AdaCore --
|
10 |
|
|
-- --
|
11 |
|
|
-- GNAT is free software; you can redistribute it and/or modify it under --
|
12 |
|
|
-- terms of the GNU General Public License as published by the Free Soft- --
|
13 |
|
|
-- ware Foundation; either version 2, or (at your option) any later ver- --
|
14 |
|
|
-- sion. GNAT is distributed in the hope that it will be useful, but WITH- --
|
15 |
|
|
-- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
|
16 |
|
|
-- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
|
17 |
|
|
-- for more details. You should have received a copy of the GNU General --
|
18 |
|
|
-- Public License distributed with GNAT; see file COPYING. If not, write --
|
19 |
|
|
-- to the Free Software Foundation, 51 Franklin Street, Fifth Floor, --
|
20 |
|
|
-- Boston, MA 02110-1301, USA. --
|
21 |
|
|
-- --
|
22 |
|
|
-- As a special exception, if other files instantiate generics from this --
|
23 |
|
|
-- unit, or you link this unit with other files to produce an executable, --
|
24 |
|
|
-- this unit does not by itself cause the resulting executable to be --
|
25 |
|
|
-- covered by the GNU General Public License. This exception does not --
|
26 |
|
|
-- however invalidate any other reasons why the executable file might be --
|
27 |
|
|
-- covered by the GNU Public License. --
|
28 |
|
|
-- --
|
29 |
|
|
-- GNAT was originally developed by the GNAT team at New York University. --
|
30 |
|
|
-- It is now maintained by Ada Core Technologies Inc (http://www.gnat.com). --
|
31 |
|
|
-- --
|
32 |
|
|
------------------------------------------------------------------------------
|
33 |
|
|
|
34 |
|
|
-- This package provides a thread-safe asynchronous communication facility
|
35 |
|
|
-- in the form of mailboxes. Individual mailbox objects are bounded in size
|
36 |
|
|
-- to a value specified by their Capacity discriminants.
|
37 |
|
|
|
38 |
|
|
-- Mailboxes actually hold references to messages, not the message values
|
39 |
|
|
-- themselves.
|
40 |
|
|
|
41 |
|
|
-- Type Mailbox is defined explicitly as a protected type (via derivation
|
42 |
|
|
-- from a protected type) so that clients may treat them accordingly (for
|
43 |
|
|
-- example, by making conditional/timed entry calls).
|
44 |
|
|
|
45 |
|
|
with System;
|
46 |
|
|
with GNAT.Bounded_Buffers;
|
47 |
|
|
|
48 |
|
|
generic
|
49 |
|
|
type Message (<>) is limited private;
|
50 |
|
|
type Message_Reference is access all Message;
|
51 |
|
|
-- Mailboxes hold references to Message values, of this type
|
52 |
|
|
|
53 |
|
|
package GNAT.Bounded_Mailboxes is
|
54 |
|
|
pragma Preelaborate;
|
55 |
|
|
|
56 |
|
|
package Message_Refs is
|
57 |
|
|
new GNAT.Bounded_Buffers (Message_Reference);
|
58 |
|
|
|
59 |
|
|
type Mailbox is new Message_Refs.Bounded_Buffer;
|
60 |
|
|
|
61 |
|
|
-- Type Mailbox has two inherited discriminants:
|
62 |
|
|
|
63 |
|
|
-- Capacity : Positive;
|
64 |
|
|
-- Capacity is the maximum number of Message references
|
65 |
|
|
-- possibly contained at any given instant.
|
66 |
|
|
|
67 |
|
|
-- Ceiling : System.Priority;
|
68 |
|
|
-- Users must specify the ceiling priority for the object.
|
69 |
|
|
-- If the Real-Time Systems Annex is not in use this value
|
70 |
|
|
-- is not important.
|
71 |
|
|
|
72 |
|
|
-- Protected type Mailbox has the following inherited interface:
|
73 |
|
|
|
74 |
|
|
-- entry Insert (Item : Message_Reference);
|
75 |
|
|
-- Insert Item into the Mailbox. Blocks caller
|
76 |
|
|
-- until space is available.
|
77 |
|
|
|
78 |
|
|
-- entry Remove (Item : out Message_Reference);
|
79 |
|
|
-- Remove next available Message_Reference from Mailbox.
|
80 |
|
|
-- Blocks caller until a Message_Reference is available.
|
81 |
|
|
|
82 |
|
|
-- function Empty return Boolean;
|
83 |
|
|
-- Returns whether the Mailbox contains any Message_References.
|
84 |
|
|
-- Note: State may change immediately after call returns.
|
85 |
|
|
|
86 |
|
|
-- function Full return Boolean;
|
87 |
|
|
-- Returns whether any space remains within the Mailbox.
|
88 |
|
|
-- Note: State may change immediately after call returns.
|
89 |
|
|
|
90 |
|
|
-- function Extent return Natural;
|
91 |
|
|
-- Returns the number of Message_Reference values currently held
|
92 |
|
|
-- within the Mailbox.
|
93 |
|
|
-- Note: State may change immediately after call returns.
|
94 |
|
|
|
95 |
|
|
Default_Ceiling : constant System.Priority := Message_Refs.Default_Ceiling;
|
96 |
|
|
-- A convenience value for the Ceiling discriminant
|
97 |
|
|
|
98 |
|
|
end GNAT.Bounded_Mailboxes;
|