diff --git a/dune-project b/dune-project index e0cd8bb..c1bbf13 100644 --- a/dune-project +++ b/dune-project @@ -37,4 +37,15 @@ (tiny_httpd (>= 0.17))) (tags (nanoev http))) +(package + (name nanoev_ezcurl) + (synopsis "Use nanoev as a basis for ezcurl") + (depends + ocaml + dune + nanoev + picos + (ezcurl (>= 0.2.4))) + (tags (nanoev http curl))) + ; See the complete stanza docs at https://dune.readthedocs.io/en/stable/reference/dune-project/index.html diff --git a/nanoev.opam b/nanoev.opam index a155b58..9fa7ba9 100644 --- a/nanoev.opam +++ b/nanoev.opam @@ -1,6 +1,6 @@ # This file is generated by dune, edit dune-project instead opam-version: "2.0" -synopsis: "Tiny event loop around `select`" +synopsis: "Tiny event loop abstraction" maintainer: ["Simon Cruanes"] authors: ["Simon Cruanes"] license: "MIT" diff --git a/nanoev_ezcurl.opam b/nanoev_ezcurl.opam new file mode 100644 index 0000000..89f660d --- /dev/null +++ b/nanoev_ezcurl.opam @@ -0,0 +1,32 @@ +# This file is generated by dune, edit dune-project instead +opam-version: "2.0" +synopsis: "Use nanoev as a basis for ezcurl" +maintainer: ["Simon Cruanes"] +authors: ["Simon Cruanes"] +license: "MIT" +tags: ["nanoev" "http" "curl"] +homepage: "https://github.com/c-cube/nanoev" +bug-reports: "https://github.com/c-cube/nanoev/issues" +depends: [ + "ocaml" + "dune" {>= "2.7"} + "nanoev" + "picos" + "ezcurl" {>= "0.2.4"} + "odoc" {with-doc} +] +build: [ + ["dune" "subst"] {dev} + [ + "dune" + "build" + "-p" + name + "-j" + jobs + "@install" + "@runtest" {with-test} + "@doc" {with-doc} + ] +] +dev-repo: "git+https://github.com/c-cube/nanoev.git" diff --git a/nanoev_tiny_httpd.opam b/nanoev_tiny_httpd.opam index db979ff..9504331 100644 --- a/nanoev_tiny_httpd.opam +++ b/nanoev_tiny_httpd.opam @@ -4,6 +4,7 @@ synopsis: "Use nanoev as a basis for tiny_httpd" maintainer: ["Simon Cruanes"] authors: ["Simon Cruanes"] license: "MIT" +tags: ["nanoev" "http"] homepage: "https://github.com/c-cube/nanoev" bug-reports: "https://github.com/c-cube/nanoev/issues" depends: [ diff --git a/src/ezcurl/dune b/src/ezcurl/dune new file mode 100644 index 0000000..f6f4b67 --- /dev/null +++ b/src/ezcurl/dune @@ -0,0 +1,9 @@ +(library + (name nanoev_ezcurl) + (public_name nanoev_ezcurl) + (libraries + threads + picos + (re_export nanoev) + nanoev.picos + (re_export ezcurl))) diff --git a/src/ezcurl/nanoev_ezcurl.ml b/src/ezcurl/nanoev_ezcurl.ml new file mode 100644 index 0000000..4fdea72 --- /dev/null +++ b/src/ezcurl/nanoev_ezcurl.ml @@ -0,0 +1,22 @@ +module EV = Nanoev_picos +include Ezcurl_core + +open struct + (* TODO: have a thread-local multi handle? *) + let multi : Curl.Multi.mt option Atomic.t = Atomic.make None + let lock = Mutex.create () + + let get_mt () = + match Atomic.get multi with + | Some mt -> mt +end + +include Ezcurl_core.Make (struct + type 'a t = 'a + + let[@inline] return x = x + let fail = raise + let ( >>= ) = ( |> ) + let ( >|= ) = ( |> ) + let perform (client : Curl.t) : Curl.curlCode = Curl.Multi.p +end) diff --git a/src/ezcurl/nanoev_ezcurl.mli b/src/ezcurl/nanoev_ezcurl.mli new file mode 100644 index 0000000..3dc26c4 --- /dev/null +++ b/src/ezcurl/nanoev_ezcurl.mli @@ -0,0 +1,5 @@ +include module type of struct + include Ezcurl_core +end + +include Ezcurl_core.S with type 'a io := 'a