Yield if the backlog is long.

This commit is contained in:
Tony Garnock-Jones 2012-05-05 23:07:20 -04:00
parent 536f1a03d2
commit de9104cdb5
1 changed files with 5 additions and 0 deletions

View File

@ -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 ()