mirror of
https://github.com/c-cube/tiny_httpd.git
synced 2025-12-05 19:00:32 -05:00
perf: use a thread pool instead
This commit is contained in:
parent
21f4743320
commit
643d1573df
2 changed files with 5 additions and 2 deletions
|
|
@ -2,4 +2,4 @@
|
|||
(executables
|
||||
(names echo)
|
||||
(flags :standard -warn-error -a+8)
|
||||
(libraries tiny_httpd tiny_httpd_camlzip))
|
||||
(libraries tiny_httpd tiny_httpd_camlzip containers-thread))
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
module S = Tiny_httpd
|
||||
|
||||
let () =
|
||||
let module TP = CCPool.Make(struct let max_size=32 end) in
|
||||
let port_ = ref 8080 in
|
||||
let j = ref 32 in
|
||||
Arg.parse (Arg.align [
|
||||
|
|
@ -10,7 +11,9 @@ let () =
|
|||
"--debug", Arg.Unit (fun () -> S._enable_debug true), " enable debug";
|
||||
"-j", Arg.Set_int j, " maximum number of connections";
|
||||
]) (fun _ -> raise (Arg.Bad "")) "echo [option]*";
|
||||
let server = S.create ~port:!port_ ~max_connections:!j () in
|
||||
let server = S.create ~port:!port_ ~max_connections:!j
|
||||
~new_thread:(fun task -> TP.run task)
|
||||
() in
|
||||
Tiny_httpd_camlzip.setup ~compress_above:1024 ~buf_size:(1024*1024) server;
|
||||
(* say hello *)
|
||||
S.add_route_handler ~meth:`GET server
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue