diff options
author | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-09-15 12:22:54 +0200 |
---|---|---|
committer | Arnaud Charlet <charlet@gcc.gnu.org> | 2011-09-15 12:22:54 +0200 |
commit | 0b5b2bbc71dfb621df534b9cc16536eb083046ce (patch) | |
tree | 02b448f73c0093fbfe3345e763787607a8a726b8 /gcc/ada/a-stwiun-shared.ads | |
parent | 21f1e8ce7288b853f431202fa3b61e12f823ae7d (diff) | |
download | gcc-0b5b2bbc71dfb621df534b9cc16536eb083046ce.tar.gz |
[multiple changes]
2011-09-15 Robert Dewar <dewar@adacore.com>
* a-cdlili.adb, a-coinve.adb, a-stzunb-shared.ads, a-suezst.adb,
a-suenco.adb, a-stwiun-shared.ads, a-cobove.adb, a-convec.adb,
a-btgbso.adb, a-cbdlli.adb, a-suewst.adb: Minor reformatting.
2011-09-15 Ed Schonberg <schonberg@adacore.com>
* sem_ch6.adb (Analyze_Expression_Function): Code cleanup:
if the expression function is not a completion, create a
new specification for the generated declaration, and keep the
original specification in the generated body. Shorter code also
ensures that proper warnings are generated for unused formals
in all cases.
2011-09-15 Sergey Rybin <rybin@adacore.com>
* tree_io.ads: Update ASIS_Version_Number because of the changes
in the tree structures for expression functions.
2011-09-15 Arnaud Charlet <charlet@adacore.com>
* s-osinte-aix.ads, s-osinte-darwin.ads, s-osinte-freebsd.ads,
s-osinte-hpux.ads, s-osinte-lynxos.ads, s-osinte-solaris-posix.ads,
s-taprop-posix.adb (CLOCK_MONOTONIC): New constant.
(CLOCK_REALTIME): Fix wrong value on some OSes.
* s-taprop-posix.adb (Monotonic_Clock): Use CLOCK_MONOTONIC.
From-SVN: r178877
Diffstat (limited to 'gcc/ada/a-stwiun-shared.ads')
-rw-r--r-- | gcc/ada/a-stwiun-shared.ads | 21 |
1 files changed, 12 insertions, 9 deletions
diff --git a/gcc/ada/a-stwiun-shared.ads b/gcc/ada/a-stwiun-shared.ads index 988463e63d2..4c05d7309ec 100644 --- a/gcc/ada/a-stwiun-shared.ads +++ b/gcc/ada/a-stwiun-shared.ads @@ -410,10 +410,10 @@ private type Shared_Wide_String (Max_Length : Natural) is limited record Counter : System.Atomic_Counters.Atomic_Counter; - -- Reference counter. + -- Reference counter - Last : Natural := 0; - Data : Wide_String (1 .. Max_Length); + Last : Natural := 0; + Data : Wide_String (1 .. Max_Length); -- Last is the index of last significant element of the Data. All -- elements with larger indices are just an extra room. end record; @@ -424,8 +424,7 @@ private -- Increment reference counter. procedure Unreference (Item : not null Shared_Wide_String_Access); - -- Decrement reference counter. Deallocate Item when reference counter is - -- zero. + -- Decrement reference counter. Deallocate Item when ref counter is zero function Can_Be_Reused (Item : Shared_Wide_String_Access; @@ -445,7 +444,7 @@ private function To_Unbounded (S : Wide_String) return Unbounded_Wide_String renames To_Unbounded_Wide_String; - -- This renames are here only to be used in the pragma Stream_Convert. + -- This renames are here only to be used in the pragma Stream_Convert type Unbounded_Wide_String is new AF.Controlled with record Reference : Shared_Wide_String_Access := Empty_Shared_Wide_String'Access; @@ -453,22 +452,25 @@ private -- The Unbounded_Wide_String uses several techniques to increase speed of -- the application: + -- - implicit sharing or copy-on-write. Unbounded_Wide_String contains -- only the reference to the data which is shared between several -- instances. The shared data is reallocated only when its value is -- changed and the object mutation can't be used or it is inefficient to -- use it; + -- - object mutation. Shared data object can be reused without memory -- reallocation when all of the following requirements are meat: -- - shared data object don't used anywhere longer; -- - its size is sufficient to store new value; -- - the gap after reuse is less then some threshold. + -- - memory preallocation. Most of used memory allocation algorithms -- aligns allocated segment on the some boundary, thus some amount of -- additional memory can be preallocated without any impact. Such -- preallocated memory can used later by Append/Insert operations -- without reallocation. - -- + -- Reference counting uses GCC builtin atomic operations, which allows to -- safely share internal data between Ada tasks. Nevertheless, this not -- make objects of Unbounded_Wide_String thread-safe, so each instance @@ -485,7 +487,8 @@ private overriding procedure Finalize (Object : in out Unbounded_Wide_String); Null_Unbounded_Wide_String : constant Unbounded_Wide_String := - (AF.Controlled with - Reference => Empty_Shared_Wide_String'Access); + (AF.Controlled with + Reference => + Empty_Shared_Wide_String'Access); end Ada.Strings.Wide_Unbounded; |