comp.lang.ada
 help / color / mirror / Atom feed
From: jsa@alexandria (Jon S Anthony)
Subject: Re: protected types and functions in Ada95 (Newbie)
Date: 1997/04/24
Date: 1997-04-24T00:00:00+00:00	[thread overview]
Message-ID: <JSA.97Apr24141538@alexandria> (raw)
In-Reply-To: 335F2DF6.827@und.ida.liu.se


In article <335F2DF6.827@und.ida.liu.se> Magnus Therning <d94magth@und.ida.liu.se> writes:

> I want to seize a semaphore in a function. Is that possible using the
> following protected type semaphore? Functions can only take 'in'
> parameters, but I need 'in out' since Seize changes the semaphore.
> 
> package Semaphore_S is
> 
>     type Kind(Num : Integer := 1) is limited private;
> 
>     procedure Seize(Sem : in out Kind);
>     procedure Release(Sem : in out Kind);

I suppose the thing to do is to use access parameters.  How do you
feel about this:

      procedure Seize(Sem : access Kind);

...

somewhere else...

function F ( Sem : access Kind ) return ... is
...
    Seize(Sem);
...
end F;


/Jon

-- 
Jon Anthony
Organon Motives, Inc.
Belmont, MA 02178
617.484.3383
jsa@organon.com





  reply	other threads:[~1997-04-24  0:00 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
1997-04-24  0:00 protected types and functions in Ada95 (Newbie) Magnus Therning
1997-04-24  0:00 ` Jon S Anthony [this message]
1997-04-24  0:00 ` Robert A Duff
1997-04-25  0:00   ` Robert Dewar
replies disabled

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