From de9104cdb54fc7fc97cc569c443b5ae8f79b2294 Mon Sep 17 00:00:00 2001 From: Tony Garnock-Jones Date: Sat, 5 May 2012 23:07:20 -0400 Subject: [PATCH] Yield if the backlog is long. --- queuenode.ml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/queuenode.ml b/queuenode.ml index 1bc8721..b32980b 100644 --- a/queuenode.ml +++ b/queuenode.ml @@ -61,6 +61,11 @@ let shoveller info = let queue_handler info n sexp = match Message.message_of_sexp sexp with | Message.Post (name, body, token) -> + lwt () = + if info.backlog > 1000 && info.waiters > 0 + then Lwt_unix.yield () + else return () + in info.backlog <- info.backlog + 1; info.backlog_out (Some body); return ()