digitalmars.D - [feature request] Special method to be called on class instance to ask
- AnimusPEXUS (10/10) Jul 31 2022 how should it work?:
- AnimusPEXUS (2/3) Jul 31 2022 warn
- vit (6/16) Aug 01 2022 Why not use
- AnimusPEXUS (5/6) Aug 01 2022 thanks, I know about those.
- Alexandru Ermicioi (3/9) Aug 02 2022 You should be able to use object destructor for that. Just be
how should it work?: when GC finds class instance which is good to be collected, it calls special function on this instance: `bool good_to_collect()`. if function returns true, then on next pass GC cleanups object without calling to `good_to_collect()`. if function returns false, then GC does nothing with object and continues periodically asking object if it's ready to be collected. `good_to_collect()` it self can be used by App, to perform cleanups, for instance destroy dependent objects.
Jul 31 2022
On Monday, 1 August 2022 at 05:33:02 UTC, AnimusPEXUS wrote:warkwarn
Jul 31 2022
On Monday, 1 August 2022 at 05:33:02 UTC, AnimusPEXUS wrote:how should it work?: when GC finds class instance which is good to be collected, it calls special function on this instance: `bool good_to_collect()`. if function returns true, then on next pass GC cleanups object without calling to `good_to_collect()`. if function returns false, then GC does nothing with object and continues periodically asking object if it's ready to be collected. `good_to_collect()` it self can be used by App, to perform cleanups, for instance destroy dependent objects.Why not use GC.addRoot: https://dlang.org/library/core/memory/gc.add_root.html GC.removeRoot: https://dlang.org/library/core/memory/gc.remove_root.html ?
Aug 01 2022
On Monday, 1 August 2022 at 11:21:43 UTC, vit wrote:GC.addRoot: GC.removeRoot:thanks, I know about those. But my point is not just to preserve objects from being GCed, but object's to be notified before GC, so objects could do some additional cleanups.
Aug 01 2022
On Tuesday, 2 August 2022 at 05:23:14 UTC, AnimusPEXUS wrote:On Monday, 1 August 2022 at 11:21:43 UTC, vit wrote:You should be able to use object destructor for that. Just be warned, don't use pointers in code, they may be obsolete already.GC.addRoot: GC.removeRoot:thanks, I know about those. But my point is not just to preserve objects from being GCed, but object's to be notified before GC, so objects could do some additional cleanups.
Aug 02 2022