----------------------------------------------------------------------
-- Demo: delay alternative
----------------------------------------------------------------------

with Stringpack; use Stringpack;
procedure Watchdog_Demo is

   task type Get_Info;
   type A_Get_Info is access all Get_Info;

   task type Watchdog(For_Whom: A_Get_Info) is
      entry Start(T: Duration);
      entry Ok;
   end Watchdog;

   G: aliased Get_Info;
   W: Watchdog(G'Access);

   task body Get_Info is
      Vs: Varstring;
   begin
      Print("give info");
      W.Start(60.0);
      Vs := Gettext;
      W.Ok;
   end Get_Info;

   task body Watchdog is
      D: Duration;
   begin
      accept Start(T: Duration) do
         D := T;
      end Start;

      select
         accept Ok;
         Print("got it");
      or
         delay D;
         abort For_Whom.all;
         Print("time expired");
      end select;
   end Watchdog;

begin
   null;
end Watchdog_Demo;


