comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: How to avoid unreferenced objects (mutexes etc)
Date: Tue, 15 Jan 2002 10:41:58 -0500
Date: 2002-01-15T10:41:58-05:00	[thread overview]
Message-ID: <u48j5j2gh9lse8@corp.supernews.com> (raw)
In-Reply-To: 3c429d1c.2624281@News.CIS.DFN.DE


"Dmitry A. Kazakov" <dmitry@elros.cbb-automation.de> wrote in message
news:3c429d1c.2624281@News.CIS.DFN.DE...
> Absolutely. So my suspicion goes. Or else, there must be something
> fundamentally wrong [in design] if unused objects are *really*
> required. It clearly indicates a *problem*.

The problem is that the language doesn't have a termination handler for
blocks, a la a "finally" clause in Java or Win32 Structured Exception
Handling.  So you have to create "unused" objects as a work-around.


> A "natural" solution would be to extend monitors, but alas tasks
> are not tagged.

Can't you parameterize a task with an access discriminant that binds to an
object whose type is class-wide, and then call (dispatching) operations on
that object?

type T is tagged limited null record;
procedure Op (O : access T);

task Task_Object (O : access T'Class) is ..

task body Task_Object is
begin
  ...
  Op (O);  --dispatching call to object viewed thru access discrim
  ...
end;

Now  you're free to derive types from T, and bind derived type instances to
a task.  Using this idiom obviates the need for extensible task types.


> So I chose the lesser evil = mutexes with all that nasty problems of
> error recovery, you have pointed. I really do not like it.

The language gives you primitives so that you can use to build in the
safety.  There is no problem using semaphores in Ada95, if you follow
certain idioms.








  reply	other threads:[~2002-01-15 15:41 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2002-01-11 13:48 How to avoid unreferenced objects (mutexes etc) Dmitry A. Kazakov
2002-01-11 13:52 ` Lutz Donnerhacke
2002-01-11 14:47 ` Robert A Duff
2002-01-11 18:02 ` Jeffrey Carter
2002-01-11 19:40 ` Robert Dewar
2002-01-12 10:18   ` Martin Dowie
2002-01-14  8:54   ` Dmitry A. Kazakov
2002-01-12  1:11 ` Nick Roberts
2002-01-12 22:04   ` Matthew Heaney
2002-01-13  5:45     ` Nick Roberts
2002-01-13  8:21       ` tmoran
2002-01-13 16:12         ` Nick Roberts
2002-01-13 15:08       ` Simon Wright
2002-01-15 17:53         ` Nick Roberts
2002-01-13 16:51       ` Jeffrey Carter
2002-01-14 23:32       ` Matthew Heaney
2002-01-15  8:53         ` Dmitry A. Kazakov
2002-01-14  8:31     ` Jean-Pierre Rosen
2002-01-14  9:42   ` Dmitry A. Kazakov
2002-01-15 15:41     ` Matthew Heaney [this message]
2002-01-15 16:18       ` Hyman Rosen
2002-01-15 16:57       ` Darren New
2002-01-15 18:57         ` Matthew Heaney
2002-01-16  0:57           ` Darren New
2002-01-16 16:35             ` Stephen Leake
2002-01-16 18:07               ` Darren New
2002-01-16 23:18                 ` Matthew Heaney
2002-01-16 23:04             ` Matthew Heaney
2002-01-17  0:21               ` Darren New
2002-01-16 15:18       ` Dmitry A. Kazakov
2002-01-15 18:59     ` Nick Roberts
2002-01-16 15:05       ` Dmitry A. Kazakov
2002-01-16 18:30         ` Matthew Heaney
2002-01-17  8:58           ` Dmitry A. Kazakov
2002-01-17  9:19             ` Lutz Donnerhacke
2002-01-17 10:42               ` Dmitry A. Kazakov
2002-01-17 10:55                 ` Lutz Donnerhacke
2002-01-17 15:30                   ` Dmitry A. Kazakov
2002-01-17 16:29                     ` Lutz Donnerhacke
2002-01-16 20:28         ` Robert A Duff
2002-01-17 19:05         ` Nick Roberts
replies disabled

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