From: rakusu_klein@fastmail.jp
Subject: Re: Ada.Containers and concurrent modification exception.
Date: Wed, 19 Sep 2018 11:24:32 -0700 (PDT)
Date: 2018-09-19T11:24:32-07:00 [thread overview]
Message-ID: <64f5bbad-2f06-4ea9-aa33-8c66e9cbb2a5@googlegroups.com> (raw)
In-Reply-To: <ly1s9pjxfr.fsf@pushface.org>
среда, 19 сентября 2018 г., 18:53:31 UTC+3 пользователь Simon Wright написал:
> It would be a good thing if the error was detected. Perhaps submit a bug
> report to AdaCore?
I am new in Ada, so don't know what is it — a bug or a feature.
Honestly, I just try to implement a standard containers in Ada by myself for educational purposes. In process I looking in GNU Classpath sources for an advice, and notice, that they are used an int counters (an int in Java have wrap-around semantic) in both containers and iterators for preventing working with invalid iterators. They call this a “fail-fast semantic”. So I decided to implement my own containers in that way, for example:
private
type State_Type is mod 2 ** Integer'Size;
type Map is
record
State : State_Type := State_Type'First;
Size : Natural := Natural'First;
Root : Node_Access := new Node_Object (Variant => Empty);
end record;
type Map_Access is access constant Map;
type Cursor is
record
Container : Map_Access := null;
State : State_Type := State_Type'First;
Node : Node_Access := null;
end record;
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.
After all I looked at the Ada.Containers and notice, that its Cursors does not have any kind of modification counters. So I decided to ask here about it.
next prev parent reply other threads:[~2018-09-19 18:24 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 [this message]
2018-09-21 23:27 ` Randy Brukardt
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