Shut down our flusher when we're cleaned up.

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5529 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2008-11-08 03:35:02 +00:00
parent fd74fa955f
commit 64115155ec
@@ -89,12 +89,12 @@ public class ClientDObjectMgr
}); });
// register a flush interval // register a flush interval
new Interval(client.getRunQueue()) { _flusher = new Interval(client.getRunQueue()) {
@Override @Override public void expired () {
public void expired () {
flushObjects(); flushObjects();
} }
}.schedule(FLUSH_INTERVAL, true); };
_flusher.schedule(FLUSH_INTERVAL, true);
} }
// documentation inherited from interface // documentation inherited from interface
@@ -162,10 +162,14 @@ public class ClientDObjectMgr
*/ */
public void processMessage (Message msg) public void processMessage (Message msg)
{ {
// append it to our queue if (_client.getRunQueue().isRunning()) {
_actions.append(msg); // append it to our queue
// and queue ourselves up to be run _actions.append(msg);
_client.getRunQueue().postRunnable(this); // and queue ourselves up to be run
_client.getRunQueue().postRunnable(this);
} else {
log.info("Dropping message as RunQueue is shutdown", "msg", msg);
}
} }
/** /**
@@ -230,15 +234,20 @@ public class ClientDObjectMgr
} }
} }
_penders.clear(); _penders.clear();
_flusher.cancel();
} }
protected <T extends DObject> void queueAction ( protected <T extends DObject> void queueAction (int oid, Subscriber<T> target, boolean subscribe)
int oid, Subscriber<T> target, boolean subscribe)
{ {
// queue up an action if (_client.getRunQueue().isRunning()) {
_actions.append(new ObjectAction<T>(oid, target, subscribe)); // queue up an action
// and queue up the omgr to get invoked on the invoker thread _actions.append(new ObjectAction<T>(oid, target, subscribe));
_client.getRunQueue().postRunnable(this); // and queue up the omgr to get invoked on the invoker thread
_client.getRunQueue().postRunnable(this);
} else {
log.info("Dropping subscribe action as RunQueue is stopped",
"oid", oid, "subscribe", subscribe);
}
} }
/** /**
@@ -518,6 +527,9 @@ public class ClientDObjectMgr
/** A reference to our client instance. */ /** A reference to our client instance. */
protected Client _client; protected Client _client;
/** Periodically calls {@link #flushObject}. */
protected Interval _flusher;
/** Our primary dispatch queue. */ /** Our primary dispatch queue. */
protected Queue<Object> _actions = new Queue<Object>(); protected Queue<Object> _actions = new Queue<Object>();