comp.lang.ada
 help / color / mirror / Atom feed
From: Jacob Sparre Andersen <sparre@nbi.dk>
Subject: Task with access to itself?
Date: Wed, 05 Dec 2012 14:53:53 +0100
Date: 2012-12-05T14:53:53+01:00	[thread overview]
Message-ID: <8738zk7gge.fsf@adaheads.sparre-andersen.dk> (raw)

I would like to maintain a collection of tasks, where the tasks
themselves can register their availability.

My immediate thought was to let the tasks know their own address
('Access), such that they can simply pass that to the collection of
available tasks, when they are ready.  But I haven't found a nice way to
implement that pattern, so may be I should do it a different way.

   type Handler is
   type Reference is access all Handler;

   task type Handler is
      entry Set (Self : in     Reference);
      entry Do_Stuff (...);
   end Handler;

   task body Handler is
      Pointer : Reference;
   begin
      accept Set (Self : in     Reference) do
         Pointer := Self;
      end Set;

      loop
         accept Do_Stuff (...) do
            ...
         end Do_Stuff;

         ...

         Register_As_Available (Pointer);
      end loop;
   end Handler;

Any suggestions?

Jacob
-- 
... but, following long-established custom, it is Laplace's result
that is always called, in the modern litterature, "Bayes' theorem." (Jaynes)



             reply	other threads:[~2012-12-05 13:53 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-12-05 13:53 Jacob Sparre Andersen [this message]
2012-12-05 14:18 ` Task with access to itself? Dmitry A. Kazakov
2012-12-05 16:57 ` Jeffrey Carter
2012-12-11 11:21   ` Jacob Sparre Andersen
2012-12-11 20:39     ` Jeffrey Carter
2012-12-12 20:25       ` Jacob Sparre Andersen
2012-12-12 21:11         ` Jeffrey Carter
2012-12-13  7:20           ` Jacob Sparre Andersen
2012-12-06  9:38 ` Egil Høvik
2012-12-06 19:53   ` Adam Beneschan
replies disabled

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