comp.lang.ada
 help / color / mirror / Atom feed
From: "Matthew Heaney" <mheaney@on2.com>
Subject: Re: How to avoid unreferenced objects (mutexes etc)
Date: Wed, 16 Jan 2002 18:04:26 -0500
Date: 2002-01-16T18:04:26-05:00	[thread overview]
Message-ID: <u4c1f78s5gjd05@corp.supernews.com> (raw)
In-Reply-To: 3C44CFBD.BC1ED52F@san.rr.com


"Darren New" <dnew@san.rr.com> wrote in message
news:3C44CFBD.BC1ED52F@san.rr.com...
> Sure. Now Op can't act as an entry.

I don't understand this comment.  Op is a procedure, so by definition it
isn't an entry.


> The basic problem is that if I have something that says
>   x.boop
> and boop is an entry,

I don't understand this comment.  Is x a task object, protected object, or
something else?  How can boop be anything other than an entry?

> it can only call one specific piece of code. That
> one specific piece of code has to be the one that determines whether the
> code blocks.

Can you say Boop (X), and then implement operation Boop to have the behavior
you want?


> That's not guarding an entry. If T.op dispatches, then it can't be an
> entry. If it's an entry, I can't override it.

I don't understand this comment.  If you use the syntax
   T.op
then T must be a task (or protected object).  And in that case it's an
entry, and so of course it doesn't dispatch.

If you had said:  "If Op (T) dispatches" then I would understand your
question about whether it dispatches.  But you didn't, so I'm confused.

What's wrong with saying Op (T), and implementing Op as a primitive
operation of T?


> I can't do
>   select T.op or delay 10.0 ; yadda end select;
> and have T.op be one of two different pieces of code, for example.

This is a selective entry call.  So wrap it in a dispatching operation:

function Op (O : in out T; Timeout : Duration) return Boolean is
begin
   select
      O.T_Task.Op;
      return False;
   or
      delay Timeout;
      return True;
   end select;
end Op;

Now if you say:

   Timed_Out := Op (O, 10.0);

then you get blocking and dispatching.


> The problem I had was trying to build a library wherein the framework
> instantiates a number of tasks. Each task is provided by the user of the
> framework. (Think, for example, of someone writing multiple types of
> windows in a GUI framework.) Each task would need to respond to
> different events at different times (meaning selective accepts in the
> tasks)

Don't use selective accepts in tasks.  This is old-fashioned.  Rewrite your
tasks to make blocking calls to an internal protected object.  Have
operations communicate with the task by calling the protected object, which
wakes up the waiting task.









  parent reply	other threads:[~2002-01-16 23:04 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
2002-01-16 23:04             ` Matthew Heaney [this message]
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