home *** CD-ROM | disk | FTP | other *** search
/ Geek Gadgets 1 / ADE-1.bin / ade-dist / gnat-2.06-src.tgz / tar.out / fsf / gnat / ada / s-tastim.ads < prev    next >
Text File  |  1996-09-28  |  4KB  |  107 lines

  1. ------------------------------------------------------------------------------
  2. --                                                                          --
  3. --                 GNU ADA RUNTIME LIBRARY (GNARL) COMPONENTS               --
  4. --                                                                          --
  5. --                     S Y S T E M . T A S K _ T I M E R                    --
  6. --                                                                          --
  7. --                                  S p e c                                 --
  8. --                                                                          --
  9. --                             $Revision: 1.3 $                             --
  10. --                                                                          --
  11. --       Copyright (c) 1991,1992,1993,1994, FSU, All Rights Reserved        --
  12. --                                                                          --
  13. -- GNARL is free software; you can redistribute it  and/or modify it  under --
  14. -- terms  of  the  GNU  Library General Public License  as published by the --
  15. -- Free Software  Foundation;  either version 2, or (at  your  option)  any --
  16. -- later  version.  GNARL is distributed  in the hope that  it will be use- --
  17. -- ful, but but WITHOUT ANY WARRANTY;  without even the implied warranty of --
  18. -- MERCHANTABILITY  or  FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Gen- --
  19. -- eral Library Public License  for more details.  You should have received --
  20. -- a  copy of the GNU Library General Public License along with GNARL;  see --
  21. -- file COPYING.LIB.  If not,  write to the  Free Software Foundation,  675 --
  22. -- Mass Ave, Cambridge, MA 02139, USA.                                      --
  23. --                                                                          --
  24. ------------------------------------------------------------------------------
  25.  
  26. with Ada.Finalization;
  27.  
  28. with Ada.Calendar;
  29. --  Used for, Calendar.Time
  30.  
  31. with Ada.Real_Time;
  32. --  Used for, Real_Time.Time
  33. --            Real_Time.Time_Span
  34.  
  35. with System.Task_Clock;
  36. --  Used for, Stimespec
  37.  
  38. package System.Task_Timer is
  39.  
  40.    --  The contents of this package, with the exception of Delay_Block,
  41.    --  are internal to GNARL; Delay_Block is part of the compiler interface.
  42.    --  Unfortunately, they must be visible so that they can be accessed
  43.    --  from the body of Ada.Calendar.Delays and Ada.Real_Time.Delays,
  44.    --  and they must be in the same package as
  45.    --  Delay_Block so that they can be used to implement its finalization.
  46.  
  47.    type Delay_Block is limited private;
  48.    --  An object of this type is passed by the compiler to the Wait
  49.    --  entry of each delay object
  50.    --  (e.g. Ada.Calendar.Delays.Delay_Object.Wait).  This is used by
  51.    --  the delay object implementation to queue the delay request and
  52.    --  suspend the task.
  53.  
  54.    protected Timer is
  55.       pragma Priority (Priority'Last);
  56.  
  57.       --  The following Enqueue entries enqueue elements in wake-up time
  58.       --  order using a single timer queue (time in System.Real_Time.Time).
  59.  
  60.       entry Enqueue_Time_Span
  61.         (T : in Ada.Real_Time.Time_Span;
  62.          D : access Delay_Block);
  63.       entry Enqueue_Duration
  64.          (T : in Duration;
  65.          D : access Delay_Block);
  66.       entry Enqueue_Real_Time
  67.         (T : in Ada.Real_Time.Time;
  68.          D : access Delay_Block);
  69.       entry Enqueue_Calendar_Time
  70.         (T : in Ada.Calendar.Time;
  71.          D : access Delay_Block);
  72.       procedure Dequeue (D : access Delay_Block);
  73.       procedure Service (T : out System.Task_Clock.Stimespec);
  74.       function Empty return Boolean;
  75. --  private
  76. --  Private protected operations are not currently supported by the
  77. --  compiler.
  78.       procedure Time_Enqueue
  79.         (T : in System.Task_Clock.Stimespec;
  80.          D : access Delay_Block);
  81.    end Timer;
  82.  
  83. private
  84.  
  85.    --  Signal_Object provides a simple suspension capability.
  86.  
  87.    protected type Signal_Object is
  88.       pragma Priority (Priority'Last);
  89.       entry Wait;
  90.       procedure Signal;
  91.    private
  92.       Open   : Boolean := False;
  93.    end Signal_Object;
  94.  
  95.    type Q_Link is access all Delay_Block;
  96.  
  97.    type Delay_Block is new Ada.Finalization.Limited_Controlled with record
  98.       S_O      : Signal_Object;
  99.       T        : System.Task_Clock.Stimespec;    --  wake up time
  100.       Next     : Q_Link;
  101.       Previous : Q_Link;
  102.    end record;
  103.  
  104.    procedure Finalize (Object : in out Delay_Block);
  105.  
  106. end System.Task_Timer;
  107.