[MLton-user] MLton.Thread.atomically

Matthew Fluet fluet at tti-c.org
Thu Feb 22 16:38:03 PST 2007


Wesley W. Terpstra wrote:
> Can I assume that MLton.Thread.atomically prevents a GC? 

No.  A garbage collection can occur anytime you do allocation, and ML 
code tends to allocate quite a bit (tuples, datatypes, function 
closures, etc.)

 > If it does not,
> what happens to finalizers which should run, but can't b/c there is an 
> atomic operation underway?

Finalizers are simply run when the GC signal handler runs.  While in an 
atomic section, no signal handler will run.  The signals are delivered, 
and upon leaving the atomic section, all the handlers for the delivered 
signals are run.  So, the finalizers will simply run when execution 
leaves MLton.Thread.atomically.





More information about the MLton-user mailing list