From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Task components, the rationale
Date: Wed, 13 Jul 2011 20:52:02 +0200
Date: 2011-07-13T20:52:02+02:00 [thread overview]
Message-ID: <amvut7owrm0l$.1mn2ip1iluzxa$.dlg@40tude.net> (raw)
OK, to avoid false impression that Ada was carelessly designed, it must be
said that there was a valid reason why task components are broken this way.
That is to prevent a much worse disaster when so-called Rosen's trick is
used.
Consider the pattern discussed earlier (the Rosen's trick):
type T;
task type Worker (Self : not null access T'Class);
type T is new Ada.Finalization.Limited_Controlled with record
My_Worker : Worker (T'Access);
end record;
overriding procedure Initialize (Object : in out T);
procedure Foo (Object : in out T) is abstract; -- A primitive operation
Now, if My_Worker started before completion of Initialize then this body
task body Worker is
begin
Self.Foo; -- Boom!
could call Foo of T or any of its derived type *before* Initialize, i.e.
before the object's construction is done! That would be a much worse
problem.
There is no simple solution for this. To start with tasks must be
inheritable from and their bodies must be primitive or class-wide
operations, because aggregation (composition) + Rosen's trick is
necessarily broken.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next reply other threads:[~2011-07-13 18:52 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-07-13 18:52 Dmitry A. Kazakov [this message]
2011-07-13 20:58 ` Task components, the rationale Maciej Sobczak
2011-07-14 8:52 ` Georg Bauhaus
2011-07-14 18:15 ` Maciej Sobczak
2011-07-22 23:28 ` Randy Brukardt
2011-07-14 9:23 ` Dmitry A. Kazakov
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox