Compare commits

..

No commits in common. "9d0a5dbf17d8365f24fd8774b81ae2af86ca6418" and "a14280c1a8793336051d66540db9b45599e3e62b" have entirely different histories.

8 changed files with 27 additions and 38 deletions

View file

@ -22,11 +22,9 @@ jobs:
# temporary until it's in a release
- run: opam pin picos 0.6.0 -y -n
- run: opam install odig moonpool trace
- run: opam pin . -y -n
- run: opam install . --deps-only
- run: opam install picos moonpool trace
- run: opam exec -- odig odoc --cache-dir=_doc/ nanoev nanoev-picos nanoev-posix nanoev_tiny_httpd
- run: opam exec -- odig odoc --cache-dir=_doc/ nanoev
- name: Deploy
uses: peaceiris/actions-gh-pages@v3

View file

@ -28,7 +28,4 @@ let () =
## Backends
- [x] select
- [x] poll/ppoll
- [ ] epoll
- [ ] kqueue
- [ ] uring

View file

@ -1,6 +1,6 @@
let is_setup = Global_ev.has_bg_thread
let setup = Global_ev.setup_bg_thread
let shutdown = Global_ev.shutdown_bg_thread
let is_setup = Global_.has_bg_thread
let setup = Global_.setup_bg_thread
let shutdown = Global_.shutdown_bg_thread
let with_setup ev f =
setup ev;

View file

@ -1,6 +1,9 @@
open Common_
let get_loop_exn_ : unit -> Nanoev.t = Global_ev.get_nanoev_exn
let[@inline] get_loop_exn_ () : Nanoev.t =
match Atomic.get Global_.st with
| None -> failwith "No nanoev loop installed."
| Some st -> st.nanoev
let[@inline] unwrap_ = function
| None -> ()
@ -82,7 +85,9 @@ let rec write fd buf i len =
let connect fd addr = retry_write_ fd (fun () -> Unix.connect fd addr)
let[@inline] max_fds () =
Option.fold ~none:1024 ~some:Nanoev.max_fds @@ Global_ev.get_nanoev ()
match Atomic.get Global_.st with
| None -> 1024
| Some st -> Nanoev.max_fds st.nanoev
let sleep t =
if t > 0. then (

View file

@ -1,19 +1,15 @@
(** Global loop. *)
open Common_
open struct
type st =
| None
| Some of {
active: bool Atomic.t;
nanoev: Nanoev.t;
th: Thread.t;
}
type st =
| None
| Some of {
active: bool Atomic.t;
nanoev: Nanoev.t;
th: Thread.t;
}
let st : st Atomic.t = Atomic.make None
let lock = Mutex.create ()
end
let st : st Atomic.t = Atomic.make None
let lock = Mutex.create ()
let with_lock lock f =
Mutex.lock lock;
@ -31,16 +27,6 @@ let bg_thread_ ~active ~evloop () : unit =
Nanoev.step evloop
done
let[@inline] get_nanoev () : Nanoev.t option =
match Atomic.get st with
| None -> None
| Some st -> Some st.nanoev
let[@inline] get_nanoev_exn () : Nanoev.t =
match Atomic.get st with
| None -> failwith "No nanoev loop installed in nanoev_picos"
| Some st -> st.nanoev
let[@inline] has_bg_thread () = Atomic.get st <> None
let setup_bg_thread (ev : Nanoev.t) : unit =

View file

@ -1,7 +1,6 @@
module Background_thread = Background_thread
module Base = Base
include Base
module Global_ev = Global_ev
module IO_in = IO_in
module IO_out = IO_out
module Net_client = Net_client

View file

@ -1,7 +1,6 @@
(** Basic interface with picos *)
module Background_thread = Background_thread
module Global_ev = Global_ev
(** {2 Non blocking IO primitives} *)

View file

@ -60,7 +60,12 @@ end
let establish ?backlog ?max_connections ?(exn_handler = default_exn_handler)
~spawn ~(client_handler : client_handler) addr : t =
let ev = Global_ev.get_nanoev_exn () in
let ev =
match Atomic.get Global_.st with
| Some { nanoev = ev; _ } -> ev
| None -> invalid_arg "Nanoev_picos.Net_server: no event loop installed"
in
let max_connections =
match max_connections with
| None -> Nanoev.max_fds ev