From: Stefano Zacchiroli Date: Sun, 1 Dec 2002 16:33:03 +0000 (+0000) Subject: - split threaded and non threaded implementations X-Git-Tag: V_0_0_6~29 X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=commitdiff_plain;h=c82a09fc52155246f8eaba28e9e6f32768505f76;p=helm.git - split threaded and non threaded implementations --- diff --git a/helm/DEVEL/ocaml-http/.depend b/helm/DEVEL/ocaml-http/.depend index fb9b49674..93875fc20 100644 --- a/helm/DEVEL/ocaml-http/.depend +++ b/helm/DEVEL/ocaml-http/.depend @@ -14,8 +14,8 @@ http_response.cmo: http_common.cmi http_daemon.cmi http_misc.cmi \ http_types.cmi http_response.cmi http_response.cmx: http_common.cmx http_daemon.cmx http_misc.cmx \ http_types.cmx http_response.cmi -http_tcp_server.cmo: http_tcp_server.cmi -http_tcp_server.cmx: http_tcp_server.cmi +http_tcp_server.cmo: http_threaded_tcp_server.cmi http_tcp_server.cmi +http_tcp_server.cmx: http_threaded_tcp_server.cmi http_tcp_server.cmi http_types.cmo: http_types.cmi http_types.cmx: http_types.cmi http_common.cmi: http_types.cmi diff --git a/helm/DEVEL/ocaml-http/META.in b/helm/DEVEL/ocaml-http/META.in index fbabc0973..8c325462e 100644 --- a/helm/DEVEL/ocaml-http/META.in +++ b/helm/DEVEL/ocaml-http/META.in @@ -1,5 +1,8 @@ description = "OCaml HTTP daemon library" version = "@DISTVERSION@" requires = "unix,pcre,netstring" +requires(mt) = "unix,pcre,netstring,threads" archive(byte) = "http.cma" archive(native) = "http.cmxa" +archive(mt,byte) = "http_mt.cma" +archive(mt,native) = "http_mt.cmxa" diff --git a/helm/DEVEL/ocaml-http/Makefile b/helm/DEVEL/ocaml-http/Makefile index 591b21d99..6c9b44ce8 100644 --- a/helm/DEVEL/ocaml-http/Makefile +++ b/helm/DEVEL/ocaml-http/Makefile @@ -1,11 +1,18 @@ include Makefile.defs MODULES = http_common http_misc http_types http_request http_parser http_tcp_server http_daemon http_response +THREADED_SRV = http_threaded_tcp_server +MODULES_MT = $(patsubst http_tcp_server, mt/$(THREADED_SRV) http_tcp_server, $(MODULES)) +MODULES_NON_MT = $(patsubst http_tcp_server, non_mt/$(THREADED_SRV) http_tcp_server, $(MODULES)) PUBLIC_MODULES = http_common http_types http_request http_daemon http_response DESTDIR = $(shell $(OCAMLFIND) printconf stdlib) -all: http.cma -opt: http.cmxa +all: all_non_mt all_mt +opt: opt_non_mt opt_mt +all_non_mt: http.cma +opt_non_mt: http.cmxa +all_mt: http_mt.cma +opt_mt: http_mt.cmxa world: all opt doc: *.mli $(OCAMLDOC) -html -d doc/html *.mli @@ -27,9 +34,27 @@ depend: %.cmx: %.ml %.cmi $(OCAMLOPT) -c $< -http.cma: $(patsubst %,%.cmo,$(MODULES)) +non_mt/$(THREADED_SRV).cmo: non_mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} non_mt/ + $(OCAMLC) -c $< +non_mt/$(THREADED_SRV).cmx: non_mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} non_mt/ + $(OCAMLOPT) -c $< + +mt/$(THREADED_SRV).cmo: mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} mt/ + $(OCAMLC) $(THREADS_FLAGS) -c $< +mt/$(THREADED_SRV).cmx: mt/$(THREADED_SRV).ml $(THREADED_SRV).cmi + cp $(THREADED_SRV).{cmi,mli} mt/ + $(OCAMLOPT) $(THREADS_FLAGS) -c $< + +http.cma: $(patsubst %,%.cmo,$(MODULES_NON_MT)) + $(OCAMLC) -a -o $@ $^ +http.cmxa: $(patsubst %,%.cmx,$(MODULES_NON_MT)) + $(OCAMLOPT) -a -o $@ $^ +http_mt.cma: $(patsubst %,%.cmo,$(MODULES_MT)) $(OCAMLC) -a -o $@ $^ -http.cmxa: $(patsubst %,%.cmx,$(MODULES)) +http_mt.cmxa: $(patsubst %,%.cmx,$(MODULES_MT)) $(OCAMLOPT) -a -o $@ $^ meta: META @@ -38,7 +63,10 @@ META: META.in clean: $(MAKE) -C examples/ clean - rm -f *.cm[ioax] *.cmxa *.[ao] test{,.opt} + for d in . mt non_mt; do \ + rm -f $$d/*.cm[ioax] $$d/*.cmxa $$d/*.[ao] $$d/test{,.opt}; \ + done + rm -f {mt,non_mt}/$(THREADED_SRV).mli docclean: rm -f doc/html/*.html doc/html/*.css distclean: clean docclean diff --git a/helm/DEVEL/ocaml-http/Makefile.defs b/helm/DEVEL/ocaml-http/Makefile.defs index 763a43ff0..8884bfd3d 100644 --- a/helm/DEVEL/ocaml-http/Makefile.defs +++ b/helm/DEVEL/ocaml-http/Makefile.defs @@ -1,13 +1,14 @@ PKGNAME = http DISTVERSION = $(shell dpkg-parsechangelog | egrep '^Version: ' | sed 's/^Version: //') -DEBUG_OPTS = -REQUIRES = unix pcre netstring threads -COMMON_OPTS = $(DEBUG_OPTS) -pp camlp4o -package "$(REQUIRES)" +DEBUG_FLAGS = +REQUIRES = unix pcre netstring +COMMON_FLAGS = $(DEBUG_FLAGS) -pp camlp4o -package "$(REQUIRES)" +THREADS_FLAGS = -package threads -thread OCAMLFIND = ocamlfind -OCAMLC = $(OCAMLFIND) ocamlc $(COMMON_OPTS) -thread -OCAMLOPT = $(OCAMLFIND) ocamlopt $(COMMON_OPTS) -thread -OCAMLDEP = $(OCAMLFIND) ocamldep $(COMMON_OPTS) +OCAMLC = $(OCAMLFIND) ocamlc $(COMMON_FLAGS) +OCAMLOPT = $(OCAMLFIND) ocamlopt $(COMMON_FLAGS) +OCAMLDEP = $(OCAMLFIND) ocamldep $(COMMON_FLAGS) OCAMLDOC = ocamldoc DISTNAME = ocaml-http diff --git a/helm/DEVEL/ocaml-http/debian/changelog b/helm/DEVEL/ocaml-http/debian/changelog index 640c37f96..3110dab7d 100644 --- a/helm/DEVEL/ocaml-http/debian/changelog +++ b/helm/DEVEL/ocaml-http/debian/changelog @@ -1,5 +1,7 @@ ocaml-http (0.0.6) unstable; urgency=low + * Now ship two versions of the library: multithreaded and + non-multithreaded * Added support for multiple binding of the same parameter in request objects (new method: 'paramAll') * Added support for 'empty' bindings in query arguments (e.g. diff --git a/helm/DEVEL/ocaml-http/examples/Makefile b/helm/DEVEL/ocaml-http/examples/Makefile index 8c74ba641..825a27567 100644 --- a/helm/DEVEL/ocaml-http/examples/Makefile +++ b/helm/DEVEL/ocaml-http/examples/Makefile @@ -1,17 +1,29 @@ include ../Makefile.defs -OBJS = ../http.cma -OBJS_OPT = ../http.cmxa -EXAMPLES_OPTS = -I .. -linkpkg +OBJS_NON_MT = ../http.cma +OBJS_NON_MT_OPT = ../http.cmxa +OBJS_MT = ../http_mt.cma +OBJS_MT_OPT = ../http_mt.cmxa +EXAMPLES_FLAGS = -I .. -linkpkg EXAMPLES = \ - always_ok_daemon webfsd obj_foo dump_args timeout dont_fork threads chdir + always_ok_daemon webfsd obj_foo dump_args timeout dont_fork threads chdir threads_foo all: $(EXAMPLES) opt: $(patsubst %,%.opt,$(EXAMPLES)) %: %.ml $(OBJS) - $(OCAMLC) $(EXAMPLES_OPTS) $(OBJS) -o $@ $< + $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_NON_MT) -o $@ $< %.opt: %.ml $(OBJS_OPT) - $(OCAMLOPT) $(EXAMPLES_OPTS) $(OBJS_OPT) -o $@ $< + $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_NON_MT_OPT) -o $@ $< + +threads: threads.ml + $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_MT) $(THREADS_FLAGS) -o $@ $< +threads.opt: threads.ml + $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_MT_OPT) $(THREADS_FLAGS) -o $@ $< + +threads_foo: threads_foo.ml + $(OCAMLC) $(EXAMPLES_FLAGS) $(OBJS_MT) $(THREADS_FLAGS) -package netclient -o $@ $< +threads_foo.opt: threads_foo.ml + $(OCAMLOPT) $(EXAMPLES_FLAGS) $(OBJS_MT_OPT) $(THREADS_FLAGS) -package netclient -o $@ $< distclean: clean clean: diff --git a/helm/DEVEL/ocaml-http/http_threaded_tcp_server.mli b/helm/DEVEL/ocaml-http/http_threaded_tcp_server.mli new file mode 100644 index 000000000..e5f7b8446 --- /dev/null +++ b/helm/DEVEL/ocaml-http/http_threaded_tcp_server.mli @@ -0,0 +1 @@ +val serve : ('a -> 'b) -> 'a -> unit diff --git a/helm/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml b/helm/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml new file mode 100644 index 000000000..2ae8e8ab7 --- /dev/null +++ b/helm/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml @@ -0,0 +1 @@ +let serve callback arg = ignore (Thread.create callback arg) diff --git a/helm/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml b/helm/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml new file mode 100644 index 000000000..729ceeb4d --- /dev/null +++ b/helm/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml @@ -0,0 +1,4 @@ +let serve _ _ = + failwith + ("Threaded server not supported by the non threaded version " ^ + "of ocaml-http, please link against http_mt.cm{,x}a")