]> gcc.gnu.org Git - gcc.git/blame - gcc/ada/s-taasde.ads
3psoccon.ads, [...]: Files added.
[gcc.git] / gcc / ada / s-taasde.ads
CommitLineData
cacbc350
RK
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-- --
07fc65c4 9-- Copyright (C) 1998-2001 Free Software Foundation, Inc. --
cacbc350
RK
10-- --
11-- GNARL 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. GNARL 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 GNARL; see file COPYING. If not, write --
19-- to the Free Software Foundation, 59 Temple Place - Suite 330, Boston, --
20-- MA 02111-1307, 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-- --
fbf5a39b
AC
29-- GNARL was developed by the GNARL team at Florida State University. --
30-- Extensive contributions were provided by Ada Core Technologies, Inc. --
cacbc350
RK
31-- --
32------------------------------------------------------------------------------
33
07fc65c4
GB
34-- This package contains the procedures to implements timeouts (delays)
35-- for asynchronous select statements.
cacbc350
RK
36
37-- Note: the compiler generates direct calls to this interface, via Rtsfind.
38-- Any changes to this interface may require corresponding compiler changes.
39
40package System.Tasking.Async_Delays is
41
42 -- Suppose the following source code is given:
43
44 -- select delay When;
45 -- ...continuation for timeout case...
46 -- then abort
47 -- ...abortable part...
48 -- end select;
49
50 -- The compiler should expand this to the following:
51
52 -- declare
53 -- DB : aliased Delay_Block;
54 -- begin
55 -- if System.Tasking.Async_Delays.Enqueue_Duration
56 -- (When, DB'Unchecked_Access)
57 -- then
58 -- begin
59 -- A101b : declare
60 -- procedure _clean is
61 -- begin
62 -- System.Tasking.Async_Delays.Cancel_Async_Delay
63 -- (DB'Unchecked_Access);
64 -- return;
65 -- end _clean;
66 -- begin
67 -- abort_undefer.all;
68 -- ...abortable part...
69 -- exception
70 -- when all others =>
71 -- declare
72 -- E105b : exception_occurrence;
73 -- begin
74 -- save_occurrence (E105b, get_current_excep.all.all);
75 -- _clean;
76 -- reraise_occurrence_no_defer (E105b);
77 -- end;
78 -- at end
79 -- _clean;
80 -- end A101b;
81 -- exception
82 -- when _abort_signal =>
83 -- abort_undefer.all;
84 -- end;
85 -- end if;
86 --
87 -- if Timed_Out (DB'Unchecked_Access) then
88 -- ...continuation for timeout case...
89 -- end if;
90 -- end;
91
92 -----------------
93 -- Delay_Block --
94 -----------------
95
96 type Delay_Block is limited private;
97 type Delay_Block_Access is access all Delay_Block;
98
99 function Enqueue_Duration
100 (T : in Duration;
101 D : Delay_Block_Access) return Boolean;
102 -- Enqueue the specified relative delay. Returns True if the delay has
103 -- been enqueued, False if it has already expired.
104 -- If the delay has been enqueued, abortion is deferred.
105
106 procedure Cancel_Async_Delay (D : Delay_Block_Access);
107 -- Cancel the specified asynchronous delay
108
109 function Timed_Out (D : Delay_Block_Access) return Boolean;
110 pragma Inline (Timed_Out);
111 -- Return True if the delay specified in D has timed out
112
113 -- There are child units for delays on Ada.Calendar.Time and
114 -- Ada.Real_Time.Time, so that an application will not need to link in
115 -- features that is not using.
116
117private
118
119 type Delay_Block is record
120 Self_Id : Task_ID;
121 -- ID of the calling task
122
123 Level : ATC_Level_Base;
124 -- Normally Level is the ATC nesting level of the
125 -- async. select statement to which this delay belongs, but
126 -- after a call has been dequeued we set it to
127 -- ATC_Level_Infinity so that the Cancel operation can
128 -- detect repeated calls, and act idempotently.
129
130 Resume_Time : Duration;
131 -- The absolute wake up time, represented as Duration
132
133 Timed_Out : Boolean := False;
134 -- Set to true if the delay has timed out
135
136 Succ, Pred : Delay_Block_Access;
137 -- A double linked list
138 end record;
139
140 -- The above "overlaying" of Self_ID and Level to hold other
141 -- data that has a non-overlapping lifetime is an unabashed
142 -- hack to save memory.
143
144 procedure Time_Enqueue
145 (T : Duration;
146 D : Delay_Block_Access);
147 pragma Inline (Time_Enqueue);
148 -- Used by the child units to enqueue delays on the timer queue
149 -- implemented in the body of this package.
150
151end System.Tasking.Async_Delays;
This page took 0.423945 seconds and 5 git commands to generate.