[MLton-commit] r5230
Wesley Terpstra
wesley at mlton.org
Sat Feb 17 06:42:20 PST 2007
make the ring thread-safe for finalizers
----------------------------------------------------------------------
U mltonlib/trunk/ca/terpstra/sqlite3/ring.sml
----------------------------------------------------------------------
Modified: mltonlib/trunk/ca/terpstra/sqlite3/ring.sml
===================================================================
--- mltonlib/trunk/ca/terpstra/sqlite3/ring.sml 2007-02-17 04:36:18 UTC (rev 5229)
+++ mltonlib/trunk/ca/terpstra/sqlite3/ring.sml 2007-02-17 14:42:20 UTC (rev 5230)
@@ -25,6 +25,7 @@
in
self
end
+ val add = fn x => MLton.Thread.atomically (fn () => add x)
fun remove (self as LINK { prev, next, value=_ }) =
let
@@ -37,17 +38,19 @@
in
()
end
+ val remove = fn x => MLton.Thread.atomically (fn () => remove x)
- fun fold f a0 (self as LINK { prev, next, value }) =
+ fun fold f a0 (self as LINK { prev=_, next, value }) =
let
- val LINK { prev=_, next=eor, value=_ } = valOf (!prev)
fun loop (l, a) =
- if l = eor then a else
case valOf (!l) of LINK { prev=_, next=nl, value=x } =>
+ if nl = next then a else
loop (nl, f (x, a))
in
loop (next, f (value, a0))
end
+ val fold = fn x => fn y => fn z =>
+ MLton.Thread.atomically (fn () => fold x y z)
fun app f = fold (fn (l, ()) => f l) ()
More information about the MLton-commit
mailing list