]> matita.cs.unibo.it Git - helm.git/commitdiff
made optional dependency on thread library and compile time flag
authorStefano Zacchiroli <zack@upsilon.cc>
Tue, 10 May 2005 10:56:45 +0000 (10:56 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Tue, 10 May 2005 10:56:45 +0000 (10:56 +0000)
helm/ocaml/METAS/meta.helm-thread.src
helm/ocaml/thread/Makefile
helm/ocaml/thread/fake/.cvsignore [new file with mode: 0644]
helm/ocaml/thread/fake/threadSafe.ml [new file with mode: 0644]
helm/ocaml/thread/fake/threadSafe.mli [new file with mode: 0644]

index 43228b1bb5000ced36aa2705d15f511c9ad18a28..5253060d2202796a7a00843df883d605278806c2 100644 (file)
@@ -1,5 +1,7 @@
-requires="threads"
+requires=""
 version="0.0.1"
-archive(byte)="thread.cma"
-archive(native)="thread.cmxa"
+archive(byte,mt)="thread.cma"
+archive(native,mt)="thread.cmxa"
+archive(byte)="thread_fake.cma"
+archive(native)="thread_fake.cmxa"
 linkopts=""
index 9818e9a0e398bf3a9d1e0a89e81ae44960d9710f..dfca8af0c69b2248478ff4c45b9ec551a8dde534 100644 (file)
@@ -4,5 +4,25 @@ REQUIRES = threads
 INTERFACE_FILES = threadSafe.mli extThread.mli
 IMPLEMENTATION_FILES = $(INTERFACE_FILES:%.mli=%.ml)
 
+all: thread_fake.cma
+opt: thread_fake.cmxa
+
 include ../Makefile.common
 
+fake/threadSafe.cmi: fake/threadSafe.mli
+       cd fake/        \
+               && ocamlfind ocamlc -c threadSafe.mli
+thread_fake.cma: fake/threadSafe.cmi
+       cd fake/        \
+               && ocamlfind ocamlc -a -o $@ threadSafe.ml      \
+               && cp $@ ../
+thread_fake.cmxa: fake/threadSafe.cmi
+       cd fake/        \
+               && ocamlfind opt -a -o $@ threadSafe.ml \
+               && cp $@ ../
+
+clean: clean_fake
+clean_fake:
+       rm -f fake/*.cm[aio] fake/*.cmxa fake/*.[ao]
+       rm -f thread_fake.cma thread_fake.cmxa
+
diff --git a/helm/ocaml/thread/fake/.cvsignore b/helm/ocaml/thread/fake/.cvsignore
new file mode 100644 (file)
index 0000000..88689d9
--- /dev/null
@@ -0,0 +1 @@
+*.cm[iaox] *.cmxa *.[ao]
diff --git a/helm/ocaml/thread/fake/threadSafe.ml b/helm/ocaml/thread/fake/threadSafe.ml
new file mode 100644 (file)
index 0000000..b2c4277
--- /dev/null
@@ -0,0 +1,35 @@
+(*
+ * Copyright (C) 2003-2005:
+ *    Stefano Zacchiroli <zack@cs.unibo.it>
+ *    for the HELM Team http://helm.cs.unibo.it/
+ *
+ *  This file is part of HELM, an Hypertextual, Electronic
+ *  Library of Mathematics, developed at the Computer Science
+ *  Department, University of Bologna, Italy.
+ *
+ *  HELM is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  HELM is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with HELM; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ *  MA  02111-1307, USA.
+ *
+ *  For details, see the HELM World-Wide-Web page,
+ *  http://helm.cs.unibo.it/
+ *)
+
+class threadSafe =
+  object
+    method private doCritical: 'a. 'a lazy_t -> 'a = fun a -> Lazy.force a
+    method private doReader: 'a. 'a lazy_t -> 'a = fun a -> Lazy.force a
+    method private doWriter: 'a. 'a lazy_t -> 'a = fun a -> Lazy.force a
+  end
+
diff --git a/helm/ocaml/thread/fake/threadSafe.mli b/helm/ocaml/thread/fake/threadSafe.mli
new file mode 100644 (file)
index 0000000..78166ab
--- /dev/null
@@ -0,0 +1,44 @@
+(*
+ * Copyright (C) 2003-2004:
+ *    Stefano Zacchiroli <zack@cs.unibo.it>
+ *    for the HELM Team http://helm.cs.unibo.it/
+ *
+ *  This file is part of HELM, an Hypertextual, Electronic
+ *  Library of Mathematics, developed at the Computer Science
+ *  Department, University of Bologna, Italy.
+ *
+ *  HELM is free software; you can redistribute it and/or
+ *  modify it under the terms of the GNU General Public License
+ *  as published by the Free Software Foundation; either version 2
+ *  of the License, or (at your option) any later version.
+ *
+ *  HELM is distributed in the hope that it will be useful,
+ *  but WITHOUT ANY WARRANTY; without even the implied warranty of
+ *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ *  GNU General Public License for more details.
+ *
+ *  You should have received a copy of the GNU General Public License
+ *  along with HELM; if not, write to the Free Software
+ *  Foundation, Inc., 59 Temple Place - Suite 330, Boston,
+ *  MA  02111-1307, USA.
+ *
+ *  For details, see the HELM World-Wide-Web page,
+ *  http://helm.cs.unibo.it/
+ *)
+
+class threadSafe:
+  object
+
+      (** execute 'action' in mutual exclusion between all other threads *)
+    method private doCritical: 'a. 'a lazy_t -> 'a
+
+      (** execute 'action' acting as a 'reader' i.e.: multiple readers can act
+      at the same time but no writer can act until no readers are acting *)
+    method private doReader: 'a. 'a lazy_t -> 'a
+
+      (** execute 'action' acting as a 'writer' i.e.: when a writer is acting,
+      no readers or writer can act, beware that writers can starve *)
+    method private doWriter: 'a. 'a lazy_t -> 'a
+
+  end
+