comp.lang.ada
 help / color / mirror / Atom feed
From: Florian Weimer <fw@deneb.enyo.de>
Subject: Re: GNAT: Unbounded_Strings
Date: 26 Jun 2001 17:28:15 +0200
Date: 2001-06-26T17:28:15+02:00	[thread overview]
Message-ID: <87hex3dzw0.fsf@deneb.enyo.de> (raw)
In-Reply-To: 9ha4gu$k32$1@news.kiev.sovam.com

"Maxim Reznik" <max1@mbank.com.ua> writes:

> Modifying of a shared string is synchronized by reference counter.
> While this counter >1 any change of shared string can't be done.

Yes, that's necessary for correct operation, and it might be
sufficient if the counter cannot raise after the comparison.

> One thing I could lose sight of is synchronization of counter itself.
> 
> Are following changes enough ?

I'm not sure, I think I would have to see the whole source code.

> I think operators
>++++
>           if Source.Share.Count.Value = 1 then
>                Change_Somehow( Source.Share.Space );
>           else
>                Make_A_Copy
>                Decrement_Count (Source.Share);
>           end if;
>++++

> are Ok, because of Count.Value=1 means that there isn't any other
> references to string and nobody can change neither Share.Count nor
> Share.Space.

I think this agrees with the letter of the ARM.  I'm still not sure if
it breaks any of my expectations regarding string types, but I

> One bad consequence of this solution is 40 bytes overhead for each strings.

You could use one global lock for all reference counter operations.
Contention on this lock isn't a problem when compared to the original
GNAT implementation because all operations which require copying a
string already involve the global allocator lock.



      reply	other threads:[~2001-06-26 15:28 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <9h9a9n$6bm$1@news.kiev.sovam.com>
2001-06-26  9:45 ` GNAT: Unbounded_Strings Florian Weimer
2001-06-26  9:46 ` Florian Weimer
2001-06-26 12:23   ` Florian Weimer
2001-06-26 13:58     ` Maxim Reznik
2001-06-26 15:28       ` Florian Weimer [this message]
replies disabled

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