]> matita.cs.unibo.it Git - helm.git/commitdiff
- split threaded and non threaded implementations
authorStefano Zacchiroli <zack@upsilon.cc>
Sun, 1 Dec 2002 16:33:03 +0000 (16:33 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Sun, 1 Dec 2002 16:33:03 +0000 (16:33 +0000)
helm/DEVEL/ocaml-http/.depend
helm/DEVEL/ocaml-http/META.in
helm/DEVEL/ocaml-http/Makefile
helm/DEVEL/ocaml-http/Makefile.defs
helm/DEVEL/ocaml-http/debian/changelog
helm/DEVEL/ocaml-http/examples/Makefile
helm/DEVEL/ocaml-http/http_threaded_tcp_server.mli [new file with mode: 0644]
helm/DEVEL/ocaml-http/mt/http_threaded_tcp_server.ml [new file with mode: 0644]
helm/DEVEL/ocaml-http/non_mt/http_threaded_tcp_server.ml [new file with mode: 0644]

index fb9b49674bcc7c3ad533c0588a2d2b175bffca71..93875fc206e0cc4922898ad0e4fbe982a2253ffc 100644 (file)
@@ -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 
index fbabc0973060a36d4d747d3c97b1b3dc29f3ace0..8c325462e847842205293eca5be75cf21124ad7e 100644 (file)
@@ -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"
index 591b21d990c0ebe5f2e47a5abfb48ef528b92c21..6c9b44ce83d605b56f65f0ac984c3264b620ab29 100644 (file)
@@ -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
index 763a43ff0febd4dc9246f5da88930a97213cb182..8884bfd3d2bbbf8c5bbac6e2b8c1cd5f811912ca 100644 (file)
@@ -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
index 640c37f969002112125b0bd0a948037f9db8b5bc..3110dab7d19631f6fda7d9a409e61b001873428d 100644 (file)
@@ -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.
index 8c74ba6413c820ec141e25b3027020fff160c65d..825a27567330c3cabbc1842a7b444ac3d0a20e0f 100644 (file)
@@ -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 (file)
index 0000000..e5f7b84
--- /dev/null
@@ -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 (file)
index 0000000..2ae8e8a
--- /dev/null
@@ -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 (file)
index 0000000..729ceeb
--- /dev/null
@@ -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")