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
This commit is contained in:
Michael Bayne
2008-08-11 20:17:36 +00:00
parent 421272f4f2
commit 5c3b5e9af3
@@ -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());
}
}
/**