From 5c3b5e9af35b864736b9e6865a2f88b894e968a6 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Mon, 11 Aug 2008 20:17:36 +0000 Subject: [PATCH] Finish off what's in our queue before allowing the writer to exit. This ensures that the LogoffRequest is sent to the server even if we have one or more pending messages on the writer's queue at the time of logoff(). git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5306 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../presents/client/BlockingCommunicator.java | 20 +++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/java/com/threerings/presents/client/BlockingCommunicator.java b/src/java/com/threerings/presents/client/BlockingCommunicator.java index b3adfd8a9..39a948ea7 100644 --- a/src/java/com/threerings/presents/client/BlockingCommunicator.java +++ b/src/java/com/threerings/presents/client/BlockingCommunicator.java @@ -684,15 +684,23 @@ public class BlockingCommunicator extends Communicator super("BlockingCommunicator_Writer"); } + @Override + public synchronized void shutdown () + { + // we want to finish off what's in our queue before we actually shutdown + postMessage(new TerminationMessage()); + } + @Override protected void iterate () { // fetch the next message from the queue UpstreamMessage msg = _msgq.get(); - // if this is a termination message, we're being requested to exit, so we want to bail - // now rather than continuing + // if this is a termination message, we're being requested to exit, so we call + // super.shutdown() to mark ourselves as not running and then return if (msg instanceof TerminationMessage) { + super.shutdown(); return; } @@ -719,14 +727,6 @@ public class BlockingCommunicator extends Communicator { writerDidExit(); } - - @Override - protected void kick () - { - // post a bogus message to the outgoing queue to ensure that the writer thread notices - // that it's time to go - postMessage(new TerminationMessage()); - } } /**