comp.lang.ada
 help / color / mirror / Atom feed
* Array not updated in procedure in protected type
@ 2010-01-22 16:26 Maksymilian Boguń
  2010-01-22 16:51 ` xavier grave
  0 siblings, 1 reply; 3+ messages in thread
From: Maksymilian Boguń @ 2010-01-22 16:26 UTC (permalink / raw)


Hi!
I created a protected object with a private array of records. When I
want to update the elements of this array, I use a procedure in this
protected object. The important part is:

My_Bird := Birds(Bird_I);
if not My_Bird.Alive then
   return;
end if;
My_Bird.Alive := False;
Birds(Bird_I) := My_Bird;

When running with debugger, I can see, that Birds(Bird_I).Alive is
False after this code is executed. However, when I switch to another
task and call this procedure again Birds(Bird_I).Alive is still True.
The array is not modified anywhere else, only through this protected
object. What is wrong, why doesn't it work?

Cheers,
-- Max



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

* Re: Array not updated in procedure in protected type
  2010-01-22 16:26 Array not updated in procedure in protected type Maksymilian Boguń
@ 2010-01-22 16:51 ` xavier grave
  2010-01-23 16:37   ` Maksymilian Boguń
  0 siblings, 1 reply; 3+ messages in thread
From: xavier grave @ 2010-01-22 16:51 UTC (permalink / raw)


-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Maksymilian Boguń a écrit :
> Hi!
> I created a protected object with a private array of records. When I
> want to update the elements of this array, I use a procedure in this
> protected object. The important part is:
> 
> My_Bird := Birds(Bird_I);
> if not My_Bird.Alive then
>    return;
> end if;
> My_Bird.Alive := False;
> Birds(Bird_I) := My_Bird;
> 
> When running with debugger, I can see, that Birds(Bird_I).Alive is
> False after this code is executed. However, when I switch to another
> task and call this procedure again Birds(Bird_I).Alive is still True.
> The array is not modified anywhere else, only through this protected
> object. What is wrong, why doesn't it work?

Can you add a little more code ?
the protected type declaration for example
or best of all : a simple test_case where this code is ?

xavier
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.10 (GNU/Linux)
Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org

iEYEARECAAYFAktZ15wACgkQVIZi0A5BZF4yzwCeM7Zhw5LlstKVWpciBpDliZhC
JLMAoKxC6mE4Zge8Ejj/mKJOdD6yAx0G
=od/+
-----END PGP SIGNATURE-----



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

* Re: Array not updated in procedure in protected type
  2010-01-22 16:51 ` xavier grave
@ 2010-01-23 16:37   ` Maksymilian Boguń
  0 siblings, 0 replies; 3+ messages in thread
From: Maksymilian Boguń @ 2010-01-23 16:37 UTC (permalink / raw)


On 22 Sty, 17:51, xavier grave <xavier.gr...@ipno.in2p3.fr> wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Maksymilian Boguń a écrit :
>
>
>
> > Hi!
> > I created a protected object with a private array of records. When I
> > want to update the elements of this array, I use a procedure in this
> > protected object. The important part is:
>
> > My_Bird := Birds(Bird_I);
> > if not My_Bird.Alive then
> >    return;
> > end if;
> > My_Bird.Alive := False;
> > Birds(Bird_I) := My_Bird;
>
> > When running with debugger, I can see, that Birds(Bird_I).Alive is
> > False after this code is executed. However, when I switch to another
> > task and call this procedure again Birds(Bird_I).Alive is still True.
> > The array is not modified anywhere else, only through this protected
> > object. What is wrong, why doesn't it work?
>
> Can you add a little more code ?
> the protected type declaration for example
> or best of all : a simple test_case where this code is ?
>
> xavier
> -----BEGIN PGP SIGNATURE-----
> Version: GnuPG v1.4.10 (GNU/Linux)
> Comment: Using GnuPG with Mozilla -http://enigmail.mozdev.org
>
> iEYEARECAAYFAktZ15wACgkQVIZi0A5BZF4yzwCeM7Zhw5LlstKVWpciBpDliZhC
> JLMAoKxC6mE4Zge8Ejj/mKJOdD6yAx0G
> =od/+
> -----END PGP SIGNATURE-----

Ah, nevermind, I solved the problem - it was a race condition in a
totally different part of the program :)
I really hate multithreaded programming :(

Cheers,
-- Max



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

end of thread, other threads:[~2010-01-23 16:37 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-01-22 16:26 Array not updated in procedure in protected type Maksymilian Boguń
2010-01-22 16:51 ` xavier grave
2010-01-23 16:37   ` Maksymilian Boguń

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