From fc5e0903e87b50a4931b66a039f75feb95b78602 Mon Sep 17 00:00:00 2001 From: Gerd Flaig Date: Sun, 26 Apr 2009 15:26:57 +0200 Subject: [PATCH] Send updates in chunks --- static/eow.js | 4 +++- web.lisp | 7 +++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/static/eow.js b/static/eow.js index 19807e4..7dedd45 100644 --- a/static/eow.js +++ b/static/eow.js @@ -74,11 +74,13 @@ function submit_cmdline(cmdline_form) { function prompt(p) { byId("prompt").textContent = p; - get_next_update(); } function msg(m) { eowOut(m); +} + +function next() { get_next_update(); } diff --git a/web.lisp b/web.lisp index 68870b9..c7ead80 100644 --- a/web.lisp +++ b/web.lisp @@ -72,9 +72,12 @@ (empire-log:info "~a: Killing update thread ~a." *empire-session* (update-thread *empire-session*)) (sb-thread:terminate-thread (update-thread *empire-session*))) (setf (update-thread *empire-session*) sb-thread:*current-thread*) - (let ((next-update (locked-queue:dequeue (update-queue *empire-session*)))) + (let ((next-updates (locked-queue:dequeue-all (update-queue *empire-session*)))) + ; There's a race here. The next update thread might kill this one before + ; sending the reply. (setf (update-thread *empire-session*) nil) - next-update))) + (nconc next-updates (list (parenscript:ps* '(next)))) + (apply #'concatenate 'string next-updates)))) (defmethod send ((s session) string) "Push a javascript update fragment to the client." -- 2.43.0