comp.lang.ada
 help / color / mirror / Atom feed
* Protected Object: little question
@ 2001-11-30 19:29 Bruno Hergott
  2001-11-30 21:15 ` Dale Stanbrough
                   ` (3 more replies)
  0 siblings, 4 replies; 8+ messages in thread
From: Bruno Hergott @ 2001-11-30 19:29 UTC (permalink / raw)


Hello,

Protected Object is really helpfull to provide read and/or write access to a ressource
in a multitask environnement.
I think i have understand the basis but something remains strange for me.

Before all, it could be better to write there the RM Ch. 9. 5.1 concerning protected
objects:
(1): A protected subprogram is a subprogram declared immediately within a
protected_definition.
Protected procedures provide exclusive read-write access to the data of a protected
object;
protected functions provide concurrent read-only access to the data.
(2): Within the body of a protected function (or a function declared immediately within a
protected_body), the current instance of the enclosing protected unit is defined to be a
constant
(that is, its subcomponents may be read but not updated). Within the body of a protected
procedure (or a procedure declared immediately within a protected_body), and within an
entry_body, the current instance is defined to be a variable (updating is permitted).
(4) A new protected action is not started on a protected object while another protected
action
on the same protected object is underway, unless both actions are the result of a call on
a
protected function. This rule is expressible in terms of the execution resource associated
with
the protected object :
 - (5) Starting a protected action on a protected object corresponds to acquiring the
execution
resource associated with the protected object, either for concurrent read-only access if
the
protected action is for a call on a protected function, or for exclusive read-write access

otherwise;
 - (6) Completing the protected action corresponds to releasing the associated execution
resource.
...

My question is:
If i want to implement an action wich does only read access to the protected data and wich
can
be called by 2 tasks at the same time, i must write a function.
But i may not need the return value of this function. Because what i want is not really a
function.
What i want is "the thing in a protected object to do only read access to the protected
data
and wich can be called by 2 tasks at the same time".
And so i must for example call this action like this:
My_Boolean_Return_Value_I_Dont_Want := My_Protected_Object.MyProtectedFunction(..);
It seems to strange to be true...

Or is there something i haven't understand ?





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

end of thread, other threads:[~2001-12-03 15:26 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2001-11-30 19:29 Protected Object: little question Bruno Hergott
2001-11-30 21:15 ` Dale Stanbrough
2001-12-01  4:00   ` Mark Lundquist
2001-12-01 15:55     ` Nick Roberts
2001-11-30 22:37 ` Jeffrey Carter
2001-12-01 10:43 ` Ehud Lamm
2001-12-03 13:24 ` John English
2001-12-03 15:26   ` Martin Dowie

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