On Thursday, 27 May 2021 at 18:13:17 UTC, Adam D. Ruppe wrote:
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.
Did you mean to add the delegate as GC root or the data? It would
be nicer to just add the delegate but addRoot does not accept it
and casting to void* is deprecated. Does it work if I supply the
.ptr property instead? This "GC silently no-op on wrong data" is
annoying.