[MLton] Bug in CML mailbox.sml

Matthew Fluet fluet@cs.cornell.edu
Sun, 13 Mar 2005 20:58:28 -0500 (EST)


> What happens is if the mbox is used as in the context of a revcEvt and
> the mailbox queue does not have a credit of msgs, but has a debit of at
> least one waiting thread the above happens.

Correct.

> Either the queued receiving thread is in the wrong atomic context or the
> switch to the queued thread assumes the wrong context.   
> 
> The one line fix below assumes the latter.  Not sure if this is THE fix
> however.

This is the correct fix, which I have checked into CVS.  Thanks.
Mailboxes are supposed to work very much like channels; you can see that 
the corresponding situation in situation in channel.sml requires a 
S.readyAndSwitch and not a S.atomicReadyAndSwitch.

I suspect the error crept in because I temporarily confused the EMPTY 
constructor corresponded to an empty queue of waiting threads, whereas it 
corresponds to an empty queue of waiting messages.

In any case, thanks very much.