comp.lang.ada
 help / color / mirror / Atom feed
* Help on Protected Objects..
@ 1996-06-21  0:00 Elias Karakoulakis
  1996-06-23  0:00 ` Robert Dewar
  0 siblings, 1 reply; 2+ messages in thread
From: Elias Karakoulakis @ 1996-06-21  0:00 UTC (permalink / raw)



Hello, I'm having a problem on protected objects and tasks.
I've built a client/server program that simulates a Bank (deposits,
withdrawals etc.) for a Course Exercise. I use a Protected Type to
handle critical actions (i.e. reading and writing to accounts), and
I've found out that calls to protected procedure WriteAccount, are
sometimes silently ignored, (I suspect when the object they try to
alter is in use.). This is my declaration part:
	protected type Treasury is
	    function ReadAccount(account:in integer) return integer;
	    procedure WriteAccount(account,amount:in integer);
	end Treasury;
How can I set the calling part to wait until the account is free?

TIA




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

* Re: Help on Protected Objects..
  1996-06-21  0:00 Help on Protected Objects Elias Karakoulakis
@ 1996-06-23  0:00 ` Robert Dewar
  0 siblings, 0 replies; 2+ messages in thread
From: Robert Dewar @ 1996-06-23  0:00 UTC (permalink / raw)


E Karakoulakis asks:

   Hello, I'm having a problem on protected objects and tasks.
   I've built a client/server program that simulates a Bank (deposits,
   withdrawals etc.) for a Course Exercise. I use a Protected Type to
   handle critical actions (i.e. reading and writing to accounts), and
   I've found out that calls to protected procedure WriteAccount, are
   sometimes silently ignored, (I suspect when the object they try to
   alter is in use.).

Either there is a bug in the compiler you are using, or your analysis
is quite wrong. Calls to protected procedures are never "silently
ignored", and you get automatic locking, that is the whole point of
protected objects. So I am afraid you will have to look elsewhere to
see why your assignment is not working. Did you put print statements
before the calls, and in the body of the protected procedure? You
probably can't do Text_IO calls in such a context (since it is likely
that Text_IO may do some potentially blocking operations), but you
can certainly call a C routine to output some debugging information,
or if you are using GNAT, use GNAT.IO for such output (GNAT.IO is
quite useful for debugging, because it does not do any potentially
blocking operations, and also it is preelaborated, so it can be
called to debug stuff in preelaborated packages.





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

end of thread, other threads:[~1996-06-23  0:00 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
1996-06-21  0:00 Help on Protected Objects Elias Karakoulakis
1996-06-23  0:00 ` Robert Dewar

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