OSDN Git Service

2007-04-20 Ed Schonberg <schonberg@adacore.com>
[pf3gnuchains/gcc-fork.git] / gcc / ada / g-tasloc.ads
index 757d3c2..ce49667 100644 (file)
@@ -6,7 +6,7 @@
 --                                                                          --
 --                                 S p e c                                  --
 --                                                                          --
---                     Copyright (C) 1998-2005, AdaCore                     --
+--                     Copyright (C) 1998-2007, AdaCore                     --
 --                                                                          --
 -- GNAT is free software;  you can  redistribute it  and/or modify it under --
 -- terms of the  GNU General Public License as published  by the Free Soft- --
 --  These routines may be used in a non-tasking program, and in that case
 --  they have no effect (they do NOT cause the tasking runtime to be loaded).
 
-package GNAT.Task_Lock is
-   pragma Elaborate_Body;
+--  See file s-tasloc.ads for full documentation of the interface
 
-   procedure Lock;
-   pragma Inline (Lock);
-   --  Acquires the global lock, starts the execution of a critical region
-   --  which no other task can enter until the locking task calls Unlock
+with System.Task_Lock;
 
-   procedure Unlock;
-   pragma Inline (Unlock);
-   --  Releases the global lock, allowing another task to successfully
-   --  complete a Lock operation. Terminates the critical region.
-   --
-   --  The recommended protocol for using these two procedures is as
-   --  follows:
-   --
-   --    Locked_Processing : begin
-   --       Lock;
-   --       ...
-   --       TSL.Unlock;
-   --
-   --    exception
-   --       when others =>
-   --          Unlock;
-   --          raise;
-   --    end Locked_Processing;
-   --
-   --  This ensures that the lock is not left set if an exception is raised
-   --  explicitly or implicitly during the critical locked region.
-   --
-   --  Note on multiple calls to Lock: It is permissible to call Lock
-   --  more than once with no intervening Unlock from a single task,
-   --  and the lock will not be released until the corresponding number
-   --  of Unlock operations has been performed. For example:
-   --
-   --    GNAT.Task_Lock.Lock;     -- acquires lock
-   --    GNAT.Task_Lock.Lock;     -- no effect
-   --    GNAT.Task_Lock.Lock;     -- no effect
-   --    GNAT.Task_Lock.Unlock;   -- no effect
-   --    GNAT.Task_Lock.Unlock;   -- no effect
-   --    GNAT.Task_Lock.Unlock;   -- releases lock
-   --
-   --  However, as previously noted, the Task_Lock facility should only
-   --  be used for very local locks where the probability of conflict is
-   --  low, so usually this kind of nesting is not a good idea in any case.
-   --  In more complex locking situations, it is more appropriate to define
-   --  an appropriate protected type to provide the required locking.
-   --
-   --  It is an error to call Unlock when there has been no prior call to
-   --  Lock. The effect of such an erroneous call is undefined, and may
-   --  result in deadlock, or other malfunction of the run-time system.
-
-end GNAT.Task_Lock;
+package GNAT.Task_Lock renames System.Task_Lock;