]> matita.cs.unibo.it Git - helm.git/blobdiff - helm/ocaml/thread/threadSafe.ml
removed no longer used METAs
[helm.git] / helm / ocaml / thread / threadSafe.ml
index 4be6618e79ec063883ffeeda3126f92a5d9a4976..afe95337038dda5276b48ab4b4af50c123a20c37 100644 (file)
  *  http://helm.cs.unibo.it/
  *)
 
+(* $Id$ *)
+
 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 +59,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 +72,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 +80,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
         ))