CVS difference for ai05s/ai05-0111-3.txt
--- ai05s/ai05-0111-3.txt 2011/01/15 07:51:41 1.7
+++ ai05s/ai05-0111-3.txt 2011/01/29 02:37:04 1.8
@@ -1,9 +1,10 @@
-!standard 4.8(2) 11-01-15 AI05-0111-3/06
+!standard 4.8(2) 11-01-28 AI05-0111-3/07
!standard 4.8(3/2)
!standard 4.8(10.3/2)
!standard 13.11(16/3)
!standard 13.11.4 (0)
!standard 13.11.5 (0)
+!standard 13.11.6 (0)
!class Amendment 10-10-13
!status work item 10-10-13
!status received 10-10-13
@@ -113,7 +114,7 @@
the specified subpool of T's storage pool, by calling Allocate_From_Subpool
as described in subclause 13.11.4.}
-Add a new section:
+Add three new clauses:
13.11.4 Storage Subpools
@@ -252,10 +253,10 @@
(including ones completed by the previous bullet) to complete their
finalization;
-* Then any of the objects allocated from the subpool that still exist
+* Next, any of the objects allocated from the subpool that still exist
are finalized in an arbitrary order;
-* Now, the following Redundant[dispatching] call is made
+* Next, the following Redundant[dispatching] call is made
System.Storage_Pools.Subpools.Deallocate_Subpool (
System.Storage_Pools.Subpools.Pool_of_Subpool(Subpool).all, Subpool);
@@ -266,63 +267,70 @@
possible effects are as given for the unchecked deallocation of an object with a
task part (see 13.11.2).
-Example
+Unchecked_Deallocate_Subpool is a potentially blocking operation (see 9.5.1).
-Here is a simple but complete implementation of the classic Mark/Release pool
-using subpools:
+13.11.6 Storage Subpool Example
+
+The following example is a simple but complete implementation of the classic
+Mark/Release pool using subpools:
+
with System.Storage_Pools.Subpools;
+with System.Storage_Elements;
with Ada.Unchecked_Deallocate_Subpool;
package MR_Pool is
+ use System.Storage_Pools;
+ -- [Note: For uses of Subpools.]
+ use System.Storage_Elements;
+ -- [Note: For uses of Storage_Count and Storage_Array.]
+
-- Mark and Release work in a stack fashion, and allocations are not allowed
-- from a subpool other than the one at the top of the stack. This is also
-- the default pool.
- subtype Subpool_Handle is System.Storage_Pools.Subpools.Subpool_Handle;
+ subtype Subpool_Handle is Subpools.Subpool_Handle;
- type Mark_Release_Pool_Type (Pool_Size : System.Storage_Elements.Storage_Count) is new
- System.Storage_Pools.Subpools.Root_Storage_Pool_with_Subpools with private;
+ type Mark_Release_Pool_Type (Pool_Size : Storage_Count) is new
+ Subpools.Root_Storage_Pool_with_Subpools with private;
function Mark (Pool : in out Mark_Release_Pool_Type;
- Storage_Size : System.Storage_Elements.Storage_Count :=
- System.Storage_Elements.Storage_Count'Last) return not null Subpool_Handle;
+ Storage_Size : Storage_Count := Storage_Count'Last) return not null Subpool_Handle;
procedure Release (Subpool : in out Subpool_Handle) renames
Ada.Unchecked_Deallocate_Subpool;
private
- type MR_Subpool is new System.Storage_Pools.Subpools.Root_Subpool with record
- Start : System.Storage_Elements.Storage_Count;
+ type MR_Subpool is new Subpools.Root_Subpool with record
+ Start : Storage_Count;
end record;
subtype Subpool_Indexes is Positive range 1 .. 10;
type Subpool_Array is array (Subpool_Indexes) of aliased MR_Subpool;
- type Mark_Release_Pool_Type (Pool_Size : System.Storage_Elements.Storage_Count) is new
- System.Storage_Pools.Subpools.Root_Storage_Pool_with_Subpools with record
- Storage : System.Storage_Elements.Storage_Array (1..Pool_Size);
- Next_Allocation : System.Storage_Elements.Storage_Count := 1;
- Markers : Subpool_Array;
+ type Mark_Release_Pool_Type (Pool_Size : Storage_Count) is new
+ Subpools.Root_Storage_Pool_with_Subpools with record
+ Storage : Storage_Array (1 .. Pool_Size);
+ Next_Allocation : Storage_Count := 1;
+ Markers : Subpool_Array;
Current_Pool : Subpool_Indexes := 1;
end record;
overriding
function Create_Subpool (Pool : aliased in out Mark_Release_Pool_Type;
- Storage_Size : System.Storage_Elements.Storage_Count :=
- System.Storage_Elements.Storage_Count'Last) return not null Subpool_Handle;
+ Storage_Size : Storage_Count := Storage_Count'Last)
+ return not null Subpool_Handle;
function Mark (Pool : in out Mark_Release_Pool_Type;
- Storage_Size : System.Storage_Elements.Storage_Count :=
- System.Storage_Elements.Storage_Count'Last) return not null Subpool_Handle
- renames Create_Subpool;
+ Storage_Size : Storage_Count := Storage_Count'Last)
+ return not null Subpool_Handle renames Create_Subpool;
overriding
procedure Allocate_From_Subpool (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
- Size_In_Storage_Elements : in System.Storage_Elements.Storage_Count;
- Alignment : in System.Storage_Elements.Storage_Count;
+ Size_In_Storage_Elements : in Storage_Count;
+ Alignment : in Storage_Count;
Subpool : not null Subpool_Handle);
overriding
@@ -338,19 +346,19 @@
procedure Allocate (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
- Size_In_Storage_Elements : in System.Storage_Elements.Storage_Count;
- Alignment : in System.Storage_Elements.Storage_Count);
+ Size_In_Storage_Elements : in Storage_Count;
+ Alignment : in Storage_Count);
overriding
procedure Deallocate (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : in System.Address;
- Size_In_Storage_Elements : in System.Storage_Elements.Storage_Count;
- Alignment : in System.Storage_Elements.Storage_Count);
+ Size_In_Storage_Elements : in Storage_Count;
+ Alignment : in Storage_Count);
overriding
function Storage_Size (Pool : Mark_Release_Pool_Type)
- return System.Storage_Elements.Storage_Count;
+ return Storage_Count;
overriding
procedure Initialize (Pool : in out Mark_Release_Pool_Type);
@@ -365,14 +373,14 @@
-- Initialize the first default subpool.
begin
Pool.Markers(1).Start := 1;
- System.Storage_Pools.Subpools.Set_Pool_for_Subpool
+ Subpools.Set_Pool_for_Subpool
(Pool.Markers(1)'Unchecked_Access,
Pool'Unchecked_Access);
end Initialize;
function Create_Subpool (Pool : in out Mark_Release_Pool_Type;
- Storage_Size : System.Storage_Elements.Storage_Count :=
- System.Storage_Elements.Storage_Count'Last) return not null Subpool_Handle is
+ Storage_Size : Storage_Count :=
+ Storage_Count'Last) return not null Subpool_Handle is
-- Mark the current allocation location.
begin
if Pool.Current_Pool = Subpool_Indexes'Last then
@@ -380,7 +388,7 @@
end if;
Pool.Current_Pool := Pool.Current_Pool + 1; -- More to the next subpool
Pool.Markers(Pool.Current_Pool).Start := Pool.Next_Allocation;
- System.Storage_Pools.Subpools.Set_Pool_for_Subpool
+ Subpools.Set_Pool_for_Subpool
(Pool.Markers(Pool.Current_Pool)'Unchecked_Access,
Pool'Unchecked_Access);
return Pool(Pool.Current_Pool).Markers'Unchecked_Access;
@@ -398,7 +406,7 @@
Pool.Current_Pool := Pool.Current_Pool - 1; -- More to the previous subpool
else -- Reinitialize the default subpool:
Pool.Next_Allocation := 1;
- System.Storage_Pools.Subpools.Set_Pool_for_Subpool
+ Subpools.Set_Pool_for_Subpool
(Pool.Markers(1)'Unchecked_Access,
Pool'Unchecked_Access);
end if;
@@ -413,8 +421,8 @@
procedure Allocate_From_Subpool (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
- Size_In_Storage_Elements : in System.Storage_Elements.Storage_Count;
- Alignment : in Storage_Elements.Storage_Count;
+ Size_In_Storage_Elements : in Storage_Count;
+ Alignment : in Storage_Count;
Subpool : not null Subpool_Handle) is
begin
if Subpool /= Pool(Pool.Current_Pool).Markers'Unchecked_Access then
@@ -426,8 +434,8 @@
procedure Allocate (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : out System.Address;
- Size_In_Storage_Elements : in System.Storage_Elements.Storage_Count;
- Alignment : in System.Storage_Elements.Storage_Count) is
+ Size_In_Storage_Elements : in Storage_Count;
+ Alignment : in Storage_Count) is
-- Allocate from the default subpool:
begin
-- Correct the alignment if necessary:
@@ -443,22 +451,22 @@
procedure Deallocate (
Pool : in out Mark_Release_Pool_Type;
Storage_Address : in System.Address;
- Size_In_Storage_Elements : in System.Storage_Elements.Storage_Count;
- Alignment : in System.Storage_Elements.Storage_Count) is
+ Size_In_Storage_Elements : in Storage_Count;
+ Alignment : in Storage_Count) is
begin
-- No deallocation other than from Release, so do nothing here.
null;
end Deallocate;
function Storage_Size (Pool : Mark_Release_Pool_Type)
- return System.Storage_Elements.Storage_Count is
+ return Storage_Count is
begin
return Pool.Pool_Size;
end Storage_Size;
end MR_Pool;
-[End 13.11.5.]
+[End 13.11.6.]
Update the existing pool example to depend on package MR_Pool as defined above:
Questions? Ask the ACAA Technical Agent