A question about moving GC

Max Samuha maxter at i.com.ua_spamless
Sat Jun 3 16:15:24 PDT 2006


On Sat, 03 Jun 2006 11:09:56 -0700, "Unknown W. Brackets"
<unknown at simplemachines.org> wrote:

>Typically, garbage collectors run only on memory 
>allocation/deallocation/similar.  They won't run in the middle of a 
>foreign program... unless it's threaded, then all bets are off.
>
>-[Unknown]
>

Thank you for prompt replies. Most programs will run more than one
thread, so it is not guaranteed that garbage collection will not be
triggered when control is in external code. What's the best way to
ensure that the pointers are valid until control is returned to D
code?

version (MovingGC/Ares/whatever)
{
	gc.pin(foo);
}
external(foo);
version (MovingGC/Ares/whatever)
{
	gc.unpin(foo);
}

that's no good. D claims it is compatible with C code but it cannot be
true unless either the specs require that D use only non-moving
garbage collector or there is a standard way to ensure that pointers
to garbage collected memory passed to external functions remain valid
while control is in external code. please correct me if i missed
something. sorry for my poor English

    



More information about the Digitalmars-d-learn mailing list