X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Focaml%2Fthread%2FthreadSafe.ml;h=affeae137922179c262c1ec7377c890182c932a5;hb=4167cea65ca58897d1a3dbb81ff95de5074700cc;hp=4be6618e79ec063883ffeeda3126f92a5d9a4976;hpb=9be60f4711fe25b98470b20c27698ccbd8c98267;p=helm.git diff --git a/helm/ocaml/thread/threadSafe.ml b/helm/ocaml/thread/threadSafe.ml index 4be6618e7..affeae137 100644 --- a/helm/ocaml/thread/threadSafe.ml +++ b/helm/ocaml/thread/threadSafe.ml @@ -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 ""; + debug_print (lazy ""); (try Mutex.lock mutex; let res = Lazy.force action in Mutex.unlock mutex; - debug_print ""; + debug_print (lazy ""); res with e -> Mutex.unlock mutex; @@ -70,7 +70,7 @@ class threadSafe = method private doReader: 'a. 'a lazy_t -> 'a = fun action -> - debug_print ""; + debug_print (lazy ""); 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 ""; + debug_print (lazy ""); res (* TODO may starve!!!! is what we want or not? *) method private doWriter: 'a. 'a lazy_t -> 'a = fun action -> - debug_print ""; + debug_print (lazy ""); self#doCritical (lazy ( while readersCount > 0 do Condition.wait noReaders mutex done; let res = Lazy.force action in - debug_print ""; + debug_print (lazy ""); res ))