[MLton] MLton.Thread.atomically

Daniel C. Wang danwang@CS.Princeton.EDU
Fri, 26 Mar 2004 13:59:01 -0500


Stephen Weeks wrote:

> What do people think about removing atomicBegin and atomicEnd from
> MLton.Thread, replacing them with a single function
> 
>   val MLton.Thread.atomically: (unit -> 'a) -> 'a
> 
> This function would do the atomicBegin and atomicEnd, but would also
> wrap the computation in a dynamicWind so that if it raises an
> exception, atomicEnd is called to end the critical section.

It be nicer to have

val MLton.Thread.make_atomic : ('a -> 'b) -> 'a -> 'b

fun atomically f = MLton.Thread.make_atomic f ()