[MLton] Stack size?

Matthew Fluet fluet@cs.cornell.edu
Fri, 8 Jul 2005 10:28:38 -0400 (EDT)


> From what I understand now, there is in fact no 'exit thread', just garbage
> collection, right? The guarantee of not returning, but instead switching 
> means that the gc's currentThread no longer points to the stack, and as long
> as it's not stored on any wait/runnable lists, it 'goes away'. =)

Correct.  From the GC's point of view, stacks/threads are just objects; 
albeit objects with a complicated structure for tracing child objects.  
The currentThread is always a root.  Any object not reached after tracing 
from the roots is collected -- including stacks/threads.

The MLton.Thread structure is fairly primitive in the operations it gives.  
It really makes sense to build a more sophisticated set of operations on 
top of it.  These operations might give

  val exitThread : unit -> 'a; (* doesn't return *)

which operationally switches to a scheduler thread without saving the 
thread switched away from.  Hence, the old thread becomes garbage and is 
collected.