switch to tail -f circular pipes
[jackhill/mal.git] / ada.2 / garbage_collected.ads
1 package Garbage_Collected is
2
3 -- A generic would not be convenient for lists. We want the
4 -- extended type to be able to have a discriminant.
5
6 -- However, we keep the dispatching in a single enumeration for
7 -- efficiency and clarity of the source.
8
9 type Instance is abstract tagged limited private;
10 subtype Class is Instance'Class;
11 type Link is access all Class;
12 subtype Pointer is not null Link;
13
14 procedure Keep_References (Object : in out Instance) is null with Inline;
15 -- A dispatching call in Keep allows subclasses to override this
16 -- in order to Keep each of the internal reference they maintain.
17
18 -- The following methods have no reason to be overridden.
19
20 procedure Keep (Object : in out Class) with Inline;
21 -- Mark this object so that it is not deleted by next clean,
22 -- then make a dispatching call to Keep_References.
23 -- Does nothing if it has already been called for this object
24 -- since startup or last Clean.
25
26 procedure Register (Ref : in Pointer) with Inline;
27 -- Each subclass defines its own allocation pool, but every call
28 -- to new must be followed by a call to Register.
29
30 procedure Clean;
31 -- For each object for which Keep has not been called since
32 -- startup or last clean, make a dispatching call to Finalize,
33 -- then deallocate the memory for the object.
34
35 -- Debug.
36 procedure Check_Allocations;
37 -- Does nothing if assertions are disabled.
38
39 private
40
41 type Instance is abstract tagged limited record
42 Kept : Boolean := False;
43 Next : Link := null;
44 end record;
45
46 end Garbage_Collected;