From cba366ace3c62fd66f99addce68ae0e243622b68 Mon Sep 17 00:00:00 2001 From: Stefano Zacchiroli Date: Tue, 10 May 2005 10:56:45 +0000 Subject: [PATCH] made optional dependency on thread library and compile time flag --- helm/ocaml/METAS/meta.helm-thread.src | 8 +++-- helm/ocaml/thread/Makefile | 20 ++++++++++++ helm/ocaml/thread/fake/.cvsignore | 1 + helm/ocaml/thread/fake/threadSafe.ml | 35 +++++++++++++++++++++ helm/ocaml/thread/fake/threadSafe.mli | 44 +++++++++++++++++++++++++++ 5 files changed, 105 insertions(+), 3 deletions(-) create mode 100644 helm/ocaml/thread/fake/.cvsignore create mode 100644 helm/ocaml/thread/fake/threadSafe.ml create mode 100644 helm/ocaml/thread/fake/threadSafe.mli diff --git a/helm/ocaml/METAS/meta.helm-thread.src b/helm/ocaml/METAS/meta.helm-thread.src index 43228b1bb..5253060d2 100644 --- a/helm/ocaml/METAS/meta.helm-thread.src +++ b/helm/ocaml/METAS/meta.helm-thread.src @@ -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="" diff --git a/helm/ocaml/thread/Makefile b/helm/ocaml/thread/Makefile index 9818e9a0e..dfca8af0c 100644 --- a/helm/ocaml/thread/Makefile +++ b/helm/ocaml/thread/Makefile @@ -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 index 000000000..88689d91a --- /dev/null +++ b/helm/ocaml/thread/fake/.cvsignore @@ -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 index 000000000..b2c427710 --- /dev/null +++ b/helm/ocaml/thread/fake/threadSafe.ml @@ -0,0 +1,35 @@ +(* + * Copyright (C) 2003-2005: + * Stefano Zacchiroli + * 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 index 000000000..78166abcc --- /dev/null +++ b/helm/ocaml/thread/fake/threadSafe.mli @@ -0,0 +1,44 @@ +(* + * Copyright (C) 2003-2004: + * Stefano Zacchiroli + * 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 + -- 2.39.2