comp.lang.ada
 help / color / mirror / Atom feed
* Finalization of a record containing a task
@ 2005-02-16 20:35 Bj?rn
  2005-02-16 20:49 ` Stephen Leake
  0 siblings, 1 reply; 15+ messages in thread
From: Bj?rn @ 2005-02-16 20:35 UTC (permalink / raw)


I'm trying to implement a form of self modifying ADT, containing an
active task.

I would prefer that the user of the ADT not need to do any "extra"
operations on the ADT when the user is finished with it, rather have
the task terminate automatically when the type goes out of scope.

I do not see how I can manage this since the ADT does not seem to
finalize as long as the tasks have not terminated.

How can I solve this? Should I rather try a different approach?

Currently it looks something like this:

package PKG is
   type T_ADT is new Limited_Controlled with private
   ...
private
   task type T_Worker is
      entry Start;
      entry Stop;
      ...
   end task;
   
   procedure Initialize (T : in out T_ADT);
   procedure Finalize (T : in out T_ADT);

   type T_ADT is new Limited_Controlled with
      record
         X : Some_Type;
         Worker : T_Worker;
      end record;
end PKG;

package body PKG is
   task T_Worker is
      {Inner task of T_Worker}
   begin
      loop
         select
            accept Start;
         or
            accept Stop;
         or
            ...
         or
            delay until Some_Time;
         end select;
      end loop;
end PKG;

Best regards,
Bj�rn



^ permalink raw reply	[flat|nested] 15+ messages in thread

end of thread, other threads:[~2005-02-22  0:15 UTC | newest]

Thread overview: 15+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-02-16 20:35 Finalization of a record containing a task Bj?rn
2005-02-16 20:49 ` Stephen Leake
2005-02-16 21:20   ` Adrien Plisson
2005-02-16 22:09     ` Robert A Duff
2005-02-17  8:24       ` Adrien Plisson
2005-02-18  0:17         ` Robert A Duff
2005-02-17  9:13     ` Dmitry A. Kazakov
2005-02-18  0:13       ` Robert A Duff
2005-02-18  2:34         ` Randy Brukardt
2005-02-18 11:27         ` Dmitry A. Kazakov
2005-02-16 22:08   ` Robert A Duff
2005-02-21 13:20     ` Craig Carey
2005-02-21 21:41       ` Robert A Duff
2005-02-22  0:15         ` Randy Brukardt
2005-02-17 17:50   ` Bj?rn

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