OSDN Git Service

2005-03-29 Vincent Celier <celier@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / a-sytaco.adb
1 ------------------------------------------------------------------------------
2 --                                                                          --
3 --                         GNAT RUNTIME COMPONENTS                          --
4 --                                                                          --
5 --         A D A . S Y N C H R O N O U S _ T A S K _ C O N T R O L          --
6 --                                                                          --
7 --                                 B o d y                                  --
8 --                                                                          --
9 --            Copyright (C) 1992-2001 Free Software Foundation, Inc.        --
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,  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 --                                                                          --
29 -- GNAT was originally developed  by the GNAT team at  New York University. --
30 -- Extensive contributions were provided by Ada Core Technologies Inc.      --
31 --                                                                          --
32 ------------------------------------------------------------------------------
33
34
35 package body Ada.Synchronous_Task_Control is
36
37    -------------------
38    -- Suspension_PO --
39    -------------------
40
41    protected body Suspension_Object is
42
43       --------------
44       -- Get_Open --
45       --------------
46
47       function Get_Open return Boolean is
48       begin
49          return Open;
50       end Get_Open;
51
52       ---------------
53       -- Set_False --
54       ---------------
55
56       procedure Set_False is
57       begin
58          Open := False;
59       end Set_False;
60
61       --------------
62       -- Set_True --
63       --------------
64
65       procedure Set_True is
66       begin
67          Open := True;
68       end Set_True;
69
70       ----------
71       -- Wait --
72       ----------
73
74       entry Wait when Open is
75       begin
76          Open := False;
77       end Wait;
78
79       --------------------
80       -- Wait_Exception --
81       --------------------
82
83       entry Wait_Exception when True is
84       begin
85          if Wait'Count /= 0 then
86             raise Program_Error;
87          end if;
88
89          requeue Wait;
90       end Wait_Exception;
91
92    end Suspension_Object;
93
94    -------------------
95    -- Current_State --
96    -------------------
97
98    function Current_State (S : Suspension_Object) return Boolean is
99    begin
100       return S.Get_Open;
101    end Current_State;
102
103    ---------------
104    -- Set_False --
105    ---------------
106
107    procedure Set_False (S : in out Suspension_Object) is
108    begin
109       S.Set_False;
110    end Set_False;
111
112    --------------
113    -- Set_True --
114    --------------
115
116    procedure Set_True (S : in out Suspension_Object) is
117    begin
118       S.Set_True;
119    end Set_True;
120
121    ------------------------
122    -- Suspend_Until_True --
123    ------------------------
124
125    procedure Suspend_Until_True (S : in out Suspension_Object) is
126    begin
127       S.Wait_Exception;
128    end Suspend_Until_True;
129
130 end Ada.Synchronous_Task_Control;