Skip to content

Commit 5df3543

Browse files
committed
Merge branch 'slides/generalized-finalization' into 'master'
Relaxed Finalization Closes #128 See merge request feng/training/material!220
2 parents cfadec0 + 4d23e3a commit 5df3543

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed

courses/fundamentals_of_ada/adv_260_controlled_types.rst

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -232,6 +232,33 @@ Unbounded String Implementation
232232
end Adjust;
233233
end Unbounded_String_Pkg;
234234
235+
------------------
236+
Finalizable Aspect
237+
------------------
238+
239+
* Uses the GNAT-specific :ada:`with Finalizable` aspect
240+
241+
.. code:: Ada
242+
243+
type Ctrl is record
244+
Id : Natural := 0;
245+
end record
246+
with Finalizable => (Initialize => Initialize,
247+
Adjust => Adjust,
248+
Finalize => Finalize,
249+
Relaxed_Finalization => True);
250+
251+
procedure Adjust (Obj : in out Ctrl);
252+
procedure Finalize (Obj : in out Ctrl);
253+
procedure Initialize (Obj : in out Ctrl);
254+
255+
* :ada:`Initialize`, :ada:`Adjust` same definition as previously
256+
* :ada:`Finalize` has the :ada:`No_Raise` aspect: it cannot raise exceptions
257+
* :ada:`Relaxed_Finalization`
258+
259+
* Performance on-par with C++'s destructor
260+
* No automatic finalization of **heap-allocated** objects
261+
235262
========
236263
Lab
237264
========

0 commit comments

Comments
 (0)