]> git.pond.sub.org Git - eow/commitdiff
Send updates in chunks
authorGerd Flaig <gefla@pond.sub.org>
Sun, 26 Apr 2009 13:26:57 +0000 (15:26 +0200)
committerGerd Flaig <gefla@pond.sub.org>
Sun, 26 Apr 2009 13:26:57 +0000 (15:26 +0200)
static/eow.js
web.lisp

index 19807e408f2a920c9390ee310b130455c26d9be2..7dedd45a9ac0d7f52ea45f0273f6b76a5c92206f 100644 (file)
@@ -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();
 }
 
index 68870b9571e2556f8d32e0a7cf48a2817d0ed1bd..c7ead803bf9f3a808610b80a10d0a286ed2447db 100644 (file)
--- a/web.lisp
+++ b/web.lisp
        (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."