From 7cbf45788889a4597ac29ab5b69949201fe0f348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rapha=C3=ABl=20Proust?= Date: Thu, 15 Nov 2018 12:28:48 +0800 Subject: [PATCH] Shell/mempool: bounded peer-workers request-queue size --- src/lib_shell/mempool_peer_worker.ml | 13 ++++++++++--- src/lib_shell/mempool_peer_worker.mli | 6 +++++- 2 files changed, 15 insertions(+), 4 deletions(-) diff --git a/src/lib_shell/mempool_peer_worker.ml b/src/lib_shell/mempool_peer_worker.ml index 82bdc7b1d..3f872b119 100644 --- a/src/lib_shell/mempool_peer_worker.ml +++ b/src/lib_shell/mempool_peer_worker.ml @@ -44,7 +44,12 @@ module type T = sig end -module Make (Mempool_worker: Mempool_worker.T) + +module type STATIC = sig + val max_pending_requests : int +end + +module Make (Static: STATIC) (Mempool_worker: Mempool_worker.T) : T with module Mempool_worker = Mempool_worker = struct @@ -318,8 +323,10 @@ module Make (Mempool_worker: Mempool_worker.T) end module Worker = Worker.Make (Name) (Event) (Request) (Types) - type t = Worker.infinite Worker.queue Worker.t - let table = Worker.create_table Queue + type t = Worker.bounded Worker.queue Worker.t + let table = + let open Worker in + create_table (Bounded { size = Static.max_pending_requests }) (* 3. Workers' work: setting workers' callbacks to perform core work *) diff --git a/src/lib_shell/mempool_peer_worker.mli b/src/lib_shell/mempool_peer_worker.mli index 62dfa7a29..144845dc7 100644 --- a/src/lib_shell/mempool_peer_worker.mli +++ b/src/lib_shell/mempool_peer_worker.mli @@ -63,5 +63,9 @@ module type T = sig end -module Make (Mempool_worker : Mempool_worker.T) +module type STATIC = sig + val max_pending_requests : int +end + +module Make (Static: STATIC) (Mempool_worker: Mempool_worker.T) : T with module Mempool_worker = Mempool_worker