From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: How to avoid unreferenced objects (mutexes etc)
Date: Wed, 16 Jan 2002 18:18:25 -0500
Date: 2002-01-16T18:18:25-05:00 [thread overview]
Message-ID: <u4c298nq0bqs1c@corp.supernews.com> (raw)
In-Reply-To: 3C45C12D.A229F569@san.rr.com
"Darren New" <dnew@san.rr.com> wrote in message
news:3C45C12D.A229F569@san.rr.com...
> Errr, no. I'm pretty sure a selective accept works in tasks.
Yes, it does, but you shouldn't bother using it. Have the task wait on a
guarded entry of a protected object, and communicate with the task by
calling a protected procedure of the protected object.
> Yes. But the problem is in the callee you want a selective accept, and
> in the caller you want a conditional entry, and you don't want those two
> tied together at compile time.
Fine. So don't tie them together at compile time. The task calls a
dispatching operation, and that dispatching operation is implemented in a
derived type by calling a guarded entry of a protected object.
The callee doesn't call an entry directly. He calls a primitive operation
that is implemented by calling an entry (of a protected object). I showed
this in my last post.
> In that case, you're screwed. If you
> could derive a task type from another task type, I'd be fine; that is,
> if I could have multiple different task bodies for the same task type,
> I'd not have had even conceptual problems.
The behavior that varies is encapsulated by calling private primitive
operations that dispatch:
package P is
type T is abstract tagged limited private;
procedure Op (O : in out T) is abstract;
private
task type T_Task_Type (O : access T'Class); --type is class-wide
type T is abstract tagged limited record
T_Task : T_Task_Type (T'Access);
end record;
procedure Wait (O : access T); --primitive
end P;
package body P is
procedure Wait (O : access T) is
begin
null;
pragma Assert (False); --must override
end;
type T_Task_Type is
begin
loop
Wait (O); -- dispatches according to tag of discriminant
...
end loop;
end T_Task_Type;
end P;
Now you can implement a derived type by extending T with a protected object,
and then overidding Wait so that it calls an entry of the protected object.
> In other words, I reimplemented Ada's entry queues.
I don't think this is necessary. Find a way to turn tasks into callers of
protected entries, so you can get rid of the select-accept statements.
next prev parent reply other threads:[~2002-01-16 23:18 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
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 [this message]
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