stopped using System.Atomic_Counters.Atomic_Counter
This commit is contained in:
@ -5,8 +5,8 @@ package body H3.MM is
|
||||
begin
|
||||
Finalize (R);
|
||||
R.Data := new Ref_Counted_Record;
|
||||
--R.Data.Ref_Count := 1;
|
||||
System.Atomic_Counters.Initialize (R.Data.Ref_Count); -- initialize to 1
|
||||
R.Data.Ref_Count := 1;
|
||||
--System.Atomic_Counters.Initialize (R.Data.Ref_Count); -- initialize to 1
|
||||
end Create;
|
||||
|
||||
procedure Create (R: in out Ref_Counted; V: in Item_Type) is
|
||||
@ -26,7 +26,8 @@ package body H3.MM is
|
||||
|
||||
function Is_Shared (R: in Ref_Counted) return Standard.Boolean is
|
||||
begin
|
||||
return R.Data /= null and then not System.Atomic_Counters.Is_One(R.Data.Ref_Count);
|
||||
--return R.Data /= null and then not System.Atomic_Counters.Is_One(R.Data.Ref_Count);
|
||||
return R.Data /= null and then R.Data.Ref_Count > 1;
|
||||
end Is_Shared;
|
||||
|
||||
procedure Initialize (R: in out Ref_Counted) is
|
||||
@ -37,8 +38,8 @@ package body H3.MM is
|
||||
procedure Adjust (R: in out Ref_Counted) is
|
||||
begin
|
||||
if R.Data /= null then
|
||||
--R.Data.Ref_Count := R.Data.Ref_Count + 1;
|
||||
System.Atomic_Counters.Increment (R.Data.Ref_Count);
|
||||
R.Data.Ref_Count := R.Data.Ref_Count + 1;
|
||||
--System.Atomic_Counters.Increment (R.Data.Ref_Count);
|
||||
end if;
|
||||
end Adjust;
|
||||
|
||||
@ -46,11 +47,16 @@ package body H3.MM is
|
||||
procedure Dealloc is new Ada.Unchecked_Deallocation(Ref_Counted_Record, Ref_Counted_Pointer);
|
||||
begin
|
||||
if R.Data /= null then
|
||||
if System.Atomic_Counters.Decrement(R.Data.Ref_Count) then
|
||||
-- The reference count reached 0
|
||||
--if System.Atomic_Counters.Decrement(R.Data.Ref_Count) then
|
||||
-- -- The reference count reached 0
|
||||
-- Dealloc (R.Data);
|
||||
-- -- R.DAta must be null here
|
||||
--end if;
|
||||
if R.Data.Ref_Count = 1 then
|
||||
Dealloc (R.Data);
|
||||
-- R.DAta must be null here
|
||||
else
|
||||
R.Data.Ref_Count := R.Data.Ref_Count - 1;
|
||||
end if;
|
||||
end if;
|
||||
end Finalize;
|
||||
end H3.MM;
|
||||
end H3.MM;
|
||||
|
Reference in New Issue
Block a user