How long does the context of a delegate exist?

Adam D. Ruppe destructionator at gmail.com
Thu May 27 18:13:17 UTC 2021


On Thursday, 27 May 2021 at 12:59:02 UTC, frame wrote:
> But what about the data used in the context of the delegate?

If the delegate is created by the GC and stored it will still be 
managed by the GC, along with its captured vars.

As long as the GC can see the delegate in your example you should 
be OK. But if it is held on to by a C or OS lib, the GC might not 
see it and you'd have to addRoot or something to ensure it stays 
in.


More information about the Digitalmars-d-learn mailing list