comp.lang.ada
 help / color / mirror / Atom feed
From: "Randy Brukardt" <randy@rrsoftware.com>
Subject: Re: Ada.Containers and concurrent modification exception.
Date: Fri, 21 Sep 2018 18:27:57 -0500
Date: 2018-09-21T18:27:57-05:00	[thread overview]
Message-ID: <po3upu$9je$1@franka.jacob-sparre.dk> (raw)
In-Reply-To: 64f5bbad-2f06-4ea9-aa33-8c66e9cbb2a5@googlegroups.com


<rakusu_klein@fastmail.jp> wrote in message 
news:64f5bbad-2f06-4ea9-aa33-8c66e9cbb2a5@googlegroups.com...

>In operations with container I just compare States in Container and Cursor 
>and
>throw a Concurent_Modification exception if they are not equal. If any 
>operation
>deletes a Node, I just increment States in Container and Cursor, if it 
>used, - it
>makes invalid any other Cursors. It may be stupid, but works well for me.

And it would be wrong: deleting a node from the Map only invalidates cursors 
that point at that node, not cursors that point at other nodes in the Map. 
Those can continue to be used (for instance, if stored in another container) 
until their nodes or the map as a whole are deleted.

You would have to use such a counter in each *node* for this to work. An 
implementation on this line is the 99% percent solution that I was 
suggesting, but it could fail in various circumstances, most likely when a 
container is destroyed and a new one created in the same location (as could 
happen with a commonly called subprogram). It also could fail if the counter 
wrapped arround (as it could if many nodes are created and destroyed 
repeatedly).

                                               Randy.



  reply	other threads:[~2018-09-21 23:27 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-09-19 13:12 Ada.Containers and concurrent modification exception rakusu_klein
2018-09-19 15:22 ` Jacob Sparre Andersen
2018-09-19 16:05   ` Simon Wright
2018-09-19 16:08     ` Jacob Sparre Andersen
2018-09-19 16:47       ` Simon Wright
2018-09-19 16:31     ` Anh Vo
2018-09-19 17:23       ` Anh Vo
2018-09-19 17:37   ` rakusu_klein
2018-09-19 18:05     ` Simon Wright
2018-09-19 15:53 ` Simon Wright
2018-09-19 18:24   ` rakusu_klein
2018-09-21 23:27     ` Randy Brukardt [this message]
2018-09-22  1:09       ` rakusu_klein
2018-09-22  8:05         ` Dmitry A. Kazakov
2018-09-22 17:49           ` rakusu_klein
2018-09-22 19:50             ` Dmitry A. Kazakov
2018-09-24 21:47         ` Randy Brukardt
2018-09-25  6:04           ` Petter Fryklund
2018-09-25 22:32             ` Randy Brukardt
2018-09-26  5:01               ` Petter Fryklund
2018-09-19 20:16 ` Jeffrey R. Carter
2018-09-19 20:56   ` rakusu_klein
2018-09-21 23:21     ` Randy Brukardt
replies disabled

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