comp.lang.ada
 help / color / mirror / Atom feed
* Abstraction - How detail should it be
@ 2007-10-08 23:23 Anh Vo
  2007-10-09  8:15 ` Dmitry A. Kazakov
  0 siblings, 1 reply; 2+ messages in thread
From: Anh Vo @ 2007-10-08 23:23 UTC (permalink / raw)


I have been reading "Concurrent and Real-Time Programming in Ada" by
Alan Burns and Andy Wellings. By the way, I ordered it about little
more than two months ago. When reading Semaphores on chapter 11
section 2 (11.2) I have noticed that semaphore abstraction seems too
low level than it should be. In addition, it treats Signal and Wait as
two separate abstractions as shown in the code below.

   type Signal_Interface is synchronized interface;
   procedure Signal (Sem : in out Signal_Interface) is abstract;
   type Any_Signal_Interface is access all Signal_Interface'Class;

   type Wait_Interface is synchronized interface;
   procedure Wait (Sem : in out Wait_Interface) is abstract;
   type Any_Wait_Interface is access all Wait_Interface'Class;

   type Semaphore_Interface is synchronized interface and
Signal_Interface
                                                           and
Wait_Interface;
   type Any_Semaphore_Interface is access all
Semaphore_Interface'Class;

However, I think that semaphore abstraction is low enough, while
operations Signal and Wait should operation on Semaphore Interface as
demonstrated below.

   type Semaphore_Interface is synchronized interface;
   procedure Signal (Sem : in out Semaphore_Interface) is abstract;
   procedure Wait (Sem : in out Semaphore_Interface) is abstract;
   type Any_Semaphore_Interface is access all
Semaphore_Interface'Class;

I would like to know which of these two abstractions is preferred and
why?
Thanks.
AV




^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: Abstraction - How detail should it be
  2007-10-08 23:23 Abstraction - How detail should it be Anh Vo
@ 2007-10-09  8:15 ` Dmitry A. Kazakov
  0 siblings, 0 replies; 2+ messages in thread
From: Dmitry A. Kazakov @ 2007-10-09  8:15 UTC (permalink / raw)


On Mon, 08 Oct 2007 23:23:49 -0000, Anh Vo wrote:

> I would like to know which of these two abstractions is preferred and
> why?

Neither, to my taste, because Wait is not exposed as an entry point.

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



^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-10-09  8:15 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2007-10-08 23:23 Abstraction - How detail should it be Anh Vo
2007-10-09  8:15 ` Dmitry A. Kazakov

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