GC and realtime threads.

Frank Benoit keinfarbton at nospam.xyz
Thu Jul 13 01:33:28 PDT 2006


chrisk schrieb:
> I'm interested in trying D for writing some audio fx plugins. Basicly the 
> plugin would be a dll with 2 threads, a GUI and an Audio thread. Is it 
> posible to prevent the GC from running during the audio thread? Can the 
> audio thread stop the CG? As the dll will be loaded into a host application 
> does that mean the GC will halt the all dll and application threads while it 
> runs?
> 
> thanks,
> 
> chris 
> 
> 

The actual implementation of the phobos GC is triggered every time you
allocate new memory. This happens if you call 'new', increase the size
of an array, use '~' or use code which does this. If your thread is only
a little piece of code, you can perhaps write it, not using any allocation.

Interrupting the GC is possible, but it is a risk. You must be sure not
to manipulate memory in a way that affects the GC. (No allocations, no
moving of references ) If you are sure it doesn't you need a way to
reactivate your thread. An OS timer? The GC uses the Thread.pauseAll.
You can use resume or just run in the OS callback?



More information about the Digitalmars-d-learn mailing list