[MLton-commit] r5405

Vesa Karvonen vesak at mlton.org
Tue Mar 6 09:15:38 PST 2007


Added RefCache and the function values to the CACHE signature.
----------------------------------------------------------------------

U   mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig
U   mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml
U   mltonlib/trunk/com/ssh/misc-util/unstable/lib.mlb
U   mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun
A   mltonlib/trunk/com/ssh/misc-util/unstable/ref-cache.sml

----------------------------------------------------------------------

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig	2007-03-06 14:50:59 UTC (rev 5404)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/cache.sig	2007-03-06 17:15:37 UTC (rev 5405)
@@ -47,4 +47,7 @@
 
    val rem : 'a t -> Key.t -> Unit.t
    (** Removes from the cache the value corresponding to the key. *)
+
+   val values : 'a t -> 'a List.t
+   (** Returns a list of values in the cache. *)
 end

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml	2007-03-06 14:50:59 UTC (rev 5404)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/cache.sml	2007-03-06 17:15:37 UTC (rev 5405)
@@ -55,4 +55,6 @@
    fun get ? = access (A.get {none = raising NotFound, some = A.return}) ?
    fun use ? = access (A.get {none = raising NotFound, some = A.remove}) ?
    fun rem ? = access (A.peek {none = raising NotFound, some = A.remove}) ?
+
+   fun values (IN {table, ...}) = T.toList table
 end

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/lib.mlb
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/lib.mlb	2007-03-06 14:50:59 UTC (rev 5404)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/lib.mlb	2007-03-06 17:15:37 UTC (rev 5405)
@@ -54,6 +54,7 @@
       cache.sml
       mk-int-obj-cache.fun
       ptr-cache.sml
+      ref-cache.sml
    end
 
    (* SML *)

Modified: mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun	2007-03-06 14:50:59 UTC (rev 5404)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/mk-int-obj-cache.fun	2007-03-06 17:15:37 UTC (rev 5405)
@@ -64,4 +64,5 @@
     ; if n*4 < cap c then realloc c (cap c div 2) else ()
    end
    fun use c k = get c k before rem c k
+   fun values c = List.tabulate (size c, #value o sub c)
 end

Added: mltonlib/trunk/com/ssh/misc-util/unstable/ref-cache.sml
===================================================================
--- mltonlib/trunk/com/ssh/misc-util/unstable/ref-cache.sml	2007-03-06 14:50:59 UTC (rev 5404)
+++ mltonlib/trunk/com/ssh/misc-util/unstable/ref-cache.sml	2007-03-06 17:15:37 UTC (rev 5405)
@@ -0,0 +1,18 @@
+(* Copyright (C) 2007 SSH Communications Security, Helsinki, Finland
+ *
+ * This code is released under the MLton license, a BSD-style license.
+ * See the LICENSE file or http://mlton.org/License for details.
+ *)
+
+local
+   structure RefIntObj : INT_OBJ = struct
+      type t = Int.t Ref.t
+      val new = ref
+      val discard = ignore
+      val get = !
+      fun set r = r <\ op :=
+   end
+in
+   (** A cache whose keys are {int ref} cells. *)
+   structure RefCache = MkIntObjCache (RefIntObj)
+end


Property changes on: mltonlib/trunk/com/ssh/misc-util/unstable/ref-cache.sml
___________________________________________________________________
Name: svn:eol-style
   + native




More information about the MLton-commit mailing list