Modify the dobjmgr and invoker such that they process the rest of their

queue and then shutdown.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2365 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-03-31 04:11:24 +00:00
parent b009981c5f
commit b20a6633b9
2 changed files with 17 additions and 10 deletions
@@ -1,5 +1,5 @@
//
// $Id: PresentsDObjectMgr.java,v 1.29 2003/03/10 18:29:54 mdb Exp $
// $Id: PresentsDObjectMgr.java,v 1.30 2003/03/31 04:11:24 mdb Exp $
package com.threerings.presents.server;
@@ -223,6 +223,12 @@ public class PresentsDObjectMgr
*/
protected void processEvent (DEvent event)
{
// handle graceful shutdown
if (event instanceof ShutdownEvent) {
_running = false;
return;
}
// look up the target object
DObject target = (DObject)_objects.get(event.getTargetOid());
if (target == null) {
@@ -278,8 +284,6 @@ public class PresentsDObjectMgr
*/
public void shutdown ()
{
_running = false;
// stick a bogus object on the event queue to ensure that the mgr
// wakes up and smells the coffee
_evqueue.append(new ShutdownEvent());
@@ -1,5 +1,5 @@
//
// $Id: Invoker.java,v 1.5 2002/10/05 23:35:21 mdb Exp $
// $Id: Invoker.java,v 1.6 2003/03/31 04:11:24 mdb Exp $
package com.threerings.presents.util;
@@ -120,17 +120,20 @@ public class Invoker extends LoopingThread
Log.warning("Invocation unit failed [unit=" + unit + "].");
Log.logStackTrace(e);
}
}
// if it's not a runnable, it was probably just an object posted
// to our queue to wake us up in time to die, so we just ignore it
} else {
// if it's not a runnable, it was just an object posted to our
// queue to wake us up and tell us to go away
_running = false;
}
}
// documentation inherited
protected void kick ()
public void shutdown ()
{
// add a non-runnable to the queue which will be ignored by the
// invoker but will cause it to wake up and go away
// we do some custom shutdown business: add a non-runnable to the
// queue which, when the invoker gets to it, will cause it to shut
// itself down
_queue.append(new Integer(0));
}