]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/thread/threadSafe.ml
ocaml 3.09 transition
[helm.git] / helm / ocaml / thread / threadSafe.ml
index 4be6618e79ec063883ffeeda3126f92a5d9a4976..affeae137922179c262c1ec7377c890182c932a5 100644 (file)
@@ -27,7 +27,7 @@
  *)
 
 let debug = false
-let debug_print s = if debug then prerr_endline s
+let debug_print s = if debug then prerr_endline (Lazy.force s)
 
 class threadSafe =
   object (self)
@@ -57,12 +57,12 @@ class threadSafe =
 
     method private doCritical: 'a. 'a lazy_t -> 'a =
       fun action ->
-        debug_print "<doCritical>";
+        debug_print (lazy "<doCritical>");
         (try
           Mutex.lock mutex;
           let res = Lazy.force action in
           Mutex.unlock mutex;
-          debug_print "</doCritical>";
+          debug_print (lazy "</doCritical>");
           res
         with e ->
           Mutex.unlock mutex;
@@ -70,7 +70,7 @@ class threadSafe =
 
     method private doReader: 'a. 'a lazy_t -> 'a =
       fun action ->
-        debug_print "<doReader>";
+        debug_print (lazy "<doReader>");
         let cleanup () =
           self#decrReadersCount;
           self#signalNoReaders
@@ -78,19 +78,19 @@ class threadSafe =
         self#incrReadersCount;
         let res = (try Lazy.force action with e -> (cleanup (); raise e)) in
         cleanup ();
-        debug_print "</doReader>";
+        debug_print (lazy "</doReader>");
         res
 
       (* TODO may starve!!!! is what we want or not? *)
     method private doWriter: 'a. 'a lazy_t -> 'a =
       fun action ->
-        debug_print "<doWriter>";
+        debug_print (lazy "<doWriter>");
         self#doCritical (lazy (
           while readersCount > 0 do
             Condition.wait noReaders mutex
           done;
           let res = Lazy.force action in
-          debug_print "</doWriter>";
+          debug_print (lazy "</doWriter>");
           res
         ))