comp.lang.ada
 help / color / mirror / Atom feed
From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Problem with task component
Date: Wed, 26 Sep 2012 16:13:06 +0200
Date: 2012-09-26T16:13:06+02:00	[thread overview]
Message-ID: <y98mzn4w9v4m$.j4mqd1bixz4f.dlg@40tude.net> (raw)
In-Reply-To: 5062ebb3$0$6583$9b4e6d93@newsspool3.arcor-online.net

On Wed, 26 Sep 2012 13:49:09 +0200, Georg Bauhaus wrote:

> On 26.09.12 09:27, Dmitry A. Kazakov wrote:
> 
>> The weakness of this approach is that the client must know its master. It
>> is almost never the case. And it is tight coupling from the software design
>> POV.
> 
> But from the software design POV, the client, or its programmer,
> always does know that there is an operational dependence if the client
> should react to the master's life cycle. I don't understand why this
> should not be made explicit?

Because it is not same as to know who is the master. We have an example at
hand: a task component. Who is the master? It could be any because the
object can be instantiated anywhere.

> Also, arguably, a master knowing the clients will create tight coupling
> too, for it could otherwise be replaced with some other master.

Master must know them at least in order to be able to spawn these tasks. 

The point is that bidirectional exchange between two tasks, e.g. when both
calls entries of each other is a bad idea anyway you turn it. Good design
always tries to have only unidirectional relationships.

>    task body Server is
>       Master_Task : M_CRef;
>    begin
>       accept Master (Master_Task : M_CRef) do

Error-prone and does not work for task components anyway.

What you indeed could do is to add a task attribute T'Master or equivalent
to get the ID of the master and then to use it as:

   Is_Callable (T'Master); -- See Ada.Task.Identification

I don't see how this is cleaner than more explicit constructs for querying
if the task is wished to terminate.

Anyway the problem is not much task termination but construction of
class-wide objects. You want to communicate with a task component that
dispatches on the container's tag upon container initialization and
finalization. That is the core problem. (BTW, note bidirectional
relationship: container -> task (component), task -> container (access
discriminant), which expectedly causes troubles).

-- 
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de



  reply	other threads:[~2012-09-26 14:12 UTC|newest]

Thread overview: 24+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-09-19 18:22 Problem with task component Simon Wright
2012-09-19 18:48 ` Dmitry A. Kazakov
2012-09-19 20:40   ` Simon Wright
2012-09-19 21:11     ` Dmitry A. Kazakov
2012-09-19 21:48       ` Simon Wright
2012-09-24  5:28         ` J-P. Rosen
2012-09-24  8:23           ` Simon Wright
2012-09-24 13:37             ` J-P. Rosen
2012-09-24 14:17               ` Simon Wright
2012-09-24 17:53               ` Robert A Duff
2012-09-24 20:40                 ` J-P. Rosen
2012-09-24 15:44             ` Adam Beneschan
2012-09-24 16:13               ` AdaMagica
2012-09-24 16:43                 ` Adam Beneschan
2012-09-24 16:29               ` Dmitry A. Kazakov
2012-09-24 20:49                 ` J-P. Rosen
2012-09-25  7:35                   ` Dmitry A. Kazakov
2012-09-25 17:52                     ` J-P. Rosen
2012-09-25 18:35                       ` Dmitry A. Kazakov
2012-09-25 19:22                         ` J-P. Rosen
2012-09-26  7:27                           ` Dmitry A. Kazakov
2012-09-26 11:49                             ` Georg Bauhaus
2012-09-26 14:13                               ` Dmitry A. Kazakov [this message]
2012-09-19 19:44 ` 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