comp.lang.ada
 help / color / mirror / Atom feed
From: rieachus@comcast.net
Subject: Re: Asynchronous channels in Ada
Date: Wed, 23 Mar 2016 19:37:45 -0700 (PDT)
Date: 2016-03-23T19:37:45-07:00	[thread overview]
Message-ID: <ba365517-7141-4b8f-9a83-431f407b4b15@googlegroups.com> (raw)
In-Reply-To: <dd09d409-78ef-4cf5-9557-e38b7042e3ab@googlegroups.com>

There is a "trick" which is very useful in certain contexts.  Your program has producer and consumer tasks, but you need occasionally to restart the channel and put everything in a consistent state:
declare
  -- queue state and exception information here.
begin
  loop
    exit when...
    begin
      task Producer...;
      task Consumer...;
    exception when ==> ...
    end;
  end loop;
end;

Your consumer task needs to use a terminate_alternative, but it should probably be doing that anyway.  This is just a skeleton scaffolding, but it should get the idea across.  If producer needs to signal an exception, it just does.  When the consumer starts up again, it looks to see what went wrong.

Of course, if your design requires that the producer and consumer tasks be on different hardware, or some such, then you do need a more complex solution. (I spent a lot of time working on systems where a "deadman" timer going off meant you had to get everything restarted inside so many milliseconds. ;-)  You do not want one too many threats to cause the aircraft's controls to lock up.


      parent reply	other threads:[~2016-03-24  2:37 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-02-19 21:02 Asynchronous channels in Ada Hadrien Grasland
2016-02-19 21:45 ` Simon Wright
2016-02-19 23:31   ` Robert A Duff
2016-02-19 21:51 ` Jeffrey R. Carter
2016-02-19 23:53   ` Brad Moore
2016-02-20  9:54 ` Dmitry A. Kazakov
2016-02-21 22:57 ` Hadrien Grasland
2016-02-22  2:30   ` Jeffrey R. Carter
2016-02-22  8:48   ` Dmitry A. Kazakov
2016-02-22  9:28   ` Georg Bauhaus
2016-02-25  7:55 ` Hadrien Grasland
2016-03-24  2:37 ` rieachus [this message]
replies disabled

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