From: "Dmitry A. Kazakov" <mailbox@dmitry-kazakov.de>
Subject: Re: Ada.Containers and concurrent modification exception.
Date: Sat, 22 Sep 2018 10:05:22 +0200
Date: 2018-09-22T10:05:22+02:00 [thread overview]
Message-ID: <po4t43$le8$1@gioia.aioe.org> (raw)
In-Reply-To: b41ee5c2-3000-442f-93cf-67116eac833a@googlegroups.com
On 2018-09-22 03:09, rakusu_klein@fastmail.jp wrote:
> суббота, 22 сентября 2018 г., 2:27:59 UTC+3 пользователь Randy Brukardt написал:
>> 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 missed the point, perhaps because I choose obscure names for properties. Sorry.
>
> State_Type is a modification's counter with a wrap-around sematic. It counts modifications of an internal container's structure and exists in all container's instances (call them Actual_Modifications) and in every iterator's instance (call them Known_Modifications). When an iterator is created for an existing container, its counter is initialized by value of that container, so their values are equal. When container is changed by any public method, its modification counter is incremented by one. If modification process by public method involves an iterator, the modification counter inside the iterator also incremented by one. Before any modification will doing, values of counters for container and iterator will be compared for equality, and if The_Container.Actual_Modifications /= The_Cursor.Known_Modifications then raise Concurent_Modification.
This schema (sequence numbers) would invalidate all cursors. Not a good
idea at all, in presence of many cursors. If there is only one cursor
then there is also no problem. So the case looks quite marginal to me.
If I wanted to cover it, provided I ever used cursors, I would rather
have the task ID to identify the owner of the change. This would be sort
of re-entrant mutex with the difference that it would raise exception
instead of blocking the offender.
In short:
1. The whole idea of fine interlocking/detection of concurrent access at
the granularity level of individual container elements is wrong. It will
never work, IMO.
2. The idea of raising exceptions concurrently at run-time to indicate
tasking design errors is even worse.
--
Regards,
Dmitry A. Kazakov
http://www.dmitry-kazakov.de
next prev parent reply other threads:[~2018-09-22 8:05 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
2018-09-22 1:09 ` rakusu_klein
2018-09-22 8:05 ` Dmitry A. Kazakov [this message]
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