From b8dbf397b72175f300a48a5245b00d0e4b4082f0 Mon Sep 17 00:00:00 2001 From: craff Date: Tue, 6 Dec 2022 16:57:37 -1000 Subject: [PATCH] .mli and .opam --- src/domains/Tiny_httpd_domains.ml | 17 +++++++++++++++++ src/domains/Tiny_httpd_domains.mli | 21 +++++++++++++++++++++ tiny_httpd_domains.opam | 4 ++-- 3 files changed, 40 insertions(+), 2 deletions(-) create mode 100644 src/domains/Tiny_httpd_domains.mli diff --git a/src/domains/Tiny_httpd_domains.ml b/src/domains/Tiny_httpd_domains.ml index 79a47505..e76076d9 100644 --- a/src/domains/Tiny_httpd_domains.ml +++ b/src/domains/Tiny_httpd_domains.ml @@ -1,4 +1,21 @@ +(** {1 Tiny Http With OCaml's domain} + This module allows for using OCaml 5 domains instead of system thread. + This enable sharing memory between task serving requests, for instance + for caching answers. + + Here is how to use: + + {[ +let pool = Domainslib.Task.setup_pool ~num_domains:4 () in +let new_thread = Tiny_httpd_domains.new_thread pool in +let server = Tiny_httpd.create ~new_thread () +.... +match Tiny_httpd_domains.run pool server with +| Ok () -> () +| Error e -> raise e + +*) let new_thread pool f = ignore (Domainslib.Task.async pool f) diff --git a/src/domains/Tiny_httpd_domains.mli b/src/domains/Tiny_httpd_domains.mli new file mode 100644 index 00000000..60598c11 --- /dev/null +++ b/src/domains/Tiny_httpd_domains.mli @@ -0,0 +1,21 @@ +(** {1 Tiny Http With OCaml's domain} + + This module allows for using OCaml 5 domains instead of system thread. + This enable sharing memory between task serving requests, for instance + for caching answers. + + Here is how to use: + + {[ +let pool = Domainslib.Task.setup_pool ~num_domains:4 () in +let new_thread = Tiny_httpd_domains.new_thread pool in +let server = Tiny_httpd.create ~new_thread () +.... +match Tiny_httpd_domains.run pool server with +| Ok () -> () +| Error e -> raise e +*) + +val new_thread : Domainslib.Task.pool -> 'a Domainslib.Task.task -> unit + +val run : Domainslib.Task.pool -> Tiny_httpd_server.t -> (unit, exn) result diff --git a/tiny_httpd_domains.opam b/tiny_httpd_domains.opam index a9a31e15..6a8bbe96 100644 --- a/tiny_httpd_domains.opam +++ b/tiny_httpd_domains.opam @@ -1,9 +1,9 @@ opam-version: "2.0" version: "0.12" authors: ["Christophe Raffalli"] -maintainer: "simon.cruanes.2007@m4x.org" +maintainer: "christophe@raffalli.eu" license: "MIT" -synopsis: "Interface to camlzip for tiny_httpd" +synopsis: "Using OCaml 5 domains instead of thread" build: [ ["dune" "build" "@install" "-p" name "-j" jobs] ["dune" "build" "@doc" "-p" name] {with-doc}