mirror of
https://github.com/c-cube/linol.git
synced 2025-12-06 03:05:31 -05:00
feat(blockingIO): allow to change the spawn function
This commit is contained in:
parent
e77fded638
commit
13feb606d2
2 changed files with 11 additions and 2 deletions
|
|
@ -14,7 +14,7 @@ let fail = raise
|
|||
let stdin = stdin
|
||||
let stdout = stdout
|
||||
|
||||
let spawn f =
|
||||
let default_spawn_ f =
|
||||
let run () =
|
||||
try f()
|
||||
with e ->
|
||||
|
|
@ -22,9 +22,14 @@ let spawn f =
|
|||
"uncaught exception in `spawn`:\n%s\n%!"
|
||||
(Printexc.to_string e));
|
||||
raise e
|
||||
in
|
||||
in
|
||||
ignore (Thread.create run () : Thread.t)
|
||||
|
||||
let spawn_ref_ = ref default_spawn_
|
||||
|
||||
let set_spawn_function f = spawn_ref_ := f
|
||||
let spawn f = !spawn_ref_ f
|
||||
|
||||
let catch f g =
|
||||
try f()
|
||||
with e -> g e
|
||||
|
|
|
|||
|
|
@ -4,3 +4,7 @@
|
|||
include Sigs.IO with type 'a t = 'a
|
||||
and type in_channel = in_channel
|
||||
and type out_channel = out_channel
|
||||
|
||||
val set_spawn_function : ((unit -> unit) -> unit) -> unit
|
||||
(** Change the way the LSP server spawns new threads to handle
|
||||
client queries. For example, one might use a thread pool. *)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue