comp.lang.ada
 help / color / mirror / Atom feed
From: Christoph Grein <Christoph.Grein@eurocopter.com>
To: comp.lang.ada@ada-france.org
Subject: Re: ATC, an  example please.
Date: Thu, 30 Jun 2005 13:06:53 +0200
Date: 2005-06-30T13:06:53+02:00	[thread overview]
Message-ID: <mailman.118.1120130788.17633.comp.lang.ada@ada-france.org> (raw)
In-Reply-To: efd7io46aiw$.1a88j118jl2sf$.dlg@40tude.net

Try the following variant of Dmitry A. Kazakov's code:

with Ada.Text_IO;

procedure ATC_Test is

  task A_Task is
    entry Start;
    entry Ready;
  end A_Task;

  task body A_Task is
  begin
    loop
      accept Start;
      Ada.Text_IO.Put_Line ("Start");
      for Iteration in 1..100_000 loop
        Ada.Text_IO.Put (".");
        delay 0.01;
      end loop;
      accept Ready;
      Ada.Text_IO.Put_Line ("Ready");
    end loop;
  end A_Task;

begin

  A_Task.Start;          -- Initiate calculation.

  select
    delay 2.0;           -- After time-out expiration, only transfer of 
control.
    Ada.Text_IO.Put_Line ("Expiration");
    delay 1.0;           -- A_Task still alive and running.
    abort A_Task;        -- Kill the task!
    Ada.Text_IO.Put_Line ("Long calculation abandoned");
  then
    abort A_Task.Ready;  -- Wait for completion.
    Ada.Text_IO.Put_Line ("Long calculation completed");
  end select;

  Ada.Text_IO.Put_Line ("End");

end ATC_Test;




  parent reply	other threads:[~2005-06-30 11:06 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-06-30  8:44 ATC, an example please e.coli
2005-06-30  9:32 ` Dmitry A. Kazakov
2005-06-30  9:59   ` e.coli
2005-06-30 11:06   ` Christoph Grein [this message]
2005-06-30 12:55   ` Robert A Duff
2005-06-30 15:29     ` Dmitry A. Kazakov
2005-06-30 20:31       ` Robert A Duff
2005-06-30  9:32 ` e.coli
2005-07-02  8:18 ` Craig Carey
replies disabled

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox