config/sparc/sol2-bi.h: Revert previous delta.
[official-gcc.git] / gcc / ada / s-taasde.ads
blob4de73b2fcc63ac2b0e4b990fe8771a666b9916a5
1 ------------------------------------------------------------------------------
2 -- --
3 -- GNU ADA RUN-TIME LIBRARY (GNARL) COMPONENTS --
4 -- --
5 -- S Y S T E M . T A S K I N G . A S Y N C _ D E L A Y S --
6 -- --
7 -- S p e c --
8 -- --
9 -- --
10 -- Copyright (C) 1998-2001 Free Software Foundation, Inc. --
11 -- --
12 -- GNARL is free software; you can redistribute it and/or modify it under --
13 -- terms of the GNU General Public License as published by the Free Soft- --
14 -- ware Foundation; either version 2, or (at your option) any later ver- --
15 -- sion. GNARL is distributed in the hope that it will be useful, but WITH- --
16 -- OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY --
17 -- or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License --
18 -- for more details. You should have received a copy of the GNU General --
19 -- Public License distributed with GNARL; see file COPYING. If not, write --
20 -- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
21 -- MA 02111-1307, USA. --
22 -- --
23 -- As a special exception, if other files instantiate generics from this --
24 -- unit, or you link this unit with other files to produce an executable, --
25 -- this unit does not by itself cause the resulting executable to be --
26 -- covered by the GNU General Public License. This exception does not --
27 -- however invalidate any other reasons why the executable file might be --
28 -- covered by the GNU Public License. --
29 -- --
30 -- GNARL was developed by the GNARL team at Florida State University. It is --
31 -- now maintained by Ada Core Technologies Inc. in cooperation with Florida --
32 -- State University (http://www.gnat.com). --
33 -- --
34 ------------------------------------------------------------------------------
36 -- This package contains the procedures to implements timeouts (delays)
37 -- for asynchronous select statements.
39 -- Note: the compiler generates direct calls to this interface, via Rtsfind.
40 -- Any changes to this interface may require corresponding compiler changes.
42 package System.Tasking.Async_Delays is
44 -- Suppose the following source code is given:
46 -- select delay When;
47 -- ...continuation for timeout case...
48 -- then abort
49 -- ...abortable part...
50 -- end select;
52 -- The compiler should expand this to the following:
54 -- declare
55 -- DB : aliased Delay_Block;
56 -- begin
57 -- if System.Tasking.Async_Delays.Enqueue_Duration
58 -- (When, DB'Unchecked_Access)
59 -- then
60 -- begin
61 -- A101b : declare
62 -- procedure _clean is
63 -- begin
64 -- System.Tasking.Async_Delays.Cancel_Async_Delay
65 -- (DB'Unchecked_Access);
66 -- return;
67 -- end _clean;
68 -- begin
69 -- abort_undefer.all;
70 -- ...abortable part...
71 -- exception
72 -- when all others =>
73 -- declare
74 -- E105b : exception_occurrence;
75 -- begin
76 -- save_occurrence (E105b, get_current_excep.all.all);
77 -- _clean;
78 -- reraise_occurrence_no_defer (E105b);
79 -- end;
80 -- at end
81 -- _clean;
82 -- end A101b;
83 -- exception
84 -- when _abort_signal =>
85 -- abort_undefer.all;
86 -- end;
87 -- end if;
89 -- if Timed_Out (DB'Unchecked_Access) then
90 -- ...continuation for timeout case...
91 -- end if;
92 -- end;
94 -----------------
95 -- Delay_Block --
96 -----------------
98 type Delay_Block is limited private;
99 type Delay_Block_Access is access all Delay_Block;
101 function Enqueue_Duration
102 (T : in Duration;
103 D : Delay_Block_Access) return Boolean;
104 -- Enqueue the specified relative delay. Returns True if the delay has
105 -- been enqueued, False if it has already expired.
106 -- If the delay has been enqueued, abortion is deferred.
108 procedure Cancel_Async_Delay (D : Delay_Block_Access);
109 -- Cancel the specified asynchronous delay
111 function Timed_Out (D : Delay_Block_Access) return Boolean;
112 pragma Inline (Timed_Out);
113 -- Return True if the delay specified in D has timed out
115 -- There are child units for delays on Ada.Calendar.Time and
116 -- Ada.Real_Time.Time, so that an application will not need to link in
117 -- features that is not using.
119 private
121 type Delay_Block is record
122 Self_Id : Task_ID;
123 -- ID of the calling task
125 Level : ATC_Level_Base;
126 -- Normally Level is the ATC nesting level of the
127 -- async. select statement to which this delay belongs, but
128 -- after a call has been dequeued we set it to
129 -- ATC_Level_Infinity so that the Cancel operation can
130 -- detect repeated calls, and act idempotently.
132 Resume_Time : Duration;
133 -- The absolute wake up time, represented as Duration
135 Timed_Out : Boolean := False;
136 -- Set to true if the delay has timed out
138 Succ, Pred : Delay_Block_Access;
139 -- A double linked list
140 end record;
142 -- The above "overlaying" of Self_ID and Level to hold other
143 -- data that has a non-overlapping lifetime is an unabashed
144 -- hack to save memory.
146 procedure Time_Enqueue
147 (T : Duration;
148 D : Delay_Block_Access);
149 pragma Inline (Time_Enqueue);
150 -- Used by the child units to enqueue delays on the timer queue
151 -- implemented in the body of this package.
153 end System.Tasking.Async_Delays;