[MLton-devel] cvs commit: Callbacks

Matthew Fluet fluet@cs.cornell.edu
Thu, 19 Jun 2003 11:53:43 -0400 (EDT)


Here is the diff for MLton.Thread.setCallFromCHandler:

>  			 val _ =
>  			    Prim.switchTo
>  			    (toPrimitive
> -			     (new (fn () => (atomicEnd ()
> -					     ; !r ()
> -					     ; Prim.setSaved t
> -					     ; Prim.returnToC ()))))
> +			     (new (fn () =>
> +				   let val (b,f) = !r in
> +				     if b then atomicEnd () else ()
> +				     ; f ()
> +				     ; Prim.setSaved t
> +				     ; if b then atomicBegin () else ()
> +				     ; Prim.returnToC ()
> +				   end)))

My question is whether the (optional) atomicBegin should occur before
Prim.setSaved t?  Under the Callback mechanism, the atomicBegin is
performed by the handler (i.e., in the  f ()  above), so it occurs before
the Prim.setSaved.  I'm just never quite sure when to do atomic operations
around thread manipulations.

If it does make sense to move the atomicBegin before the Prim.setSaved,
then it's probably just as well to drop the boolean and have
MLton.FFI.handleCallFromC compose the function with the atomicBegin/End.



-------------------------------------------------------
This SF.Net email is sponsored by: INetU
Attention Web Developers & Consultants: Become An INetU Hosting Partner.
Refer Dedicated Servers. We Manage Them. You Get 10% Monthly Commission!
INetU Dedicated Managed Hosting http://www.inetu.net/partner/index.php
_______________________________________________
MLton-devel mailing list
MLton-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/mlton-devel