Wait for everything to clear before starting the connection manager, and split out the code called when starting said manager so subclasses can override that

git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@5900 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Charlie Groves
2009-08-12 20:02:01 +00:00
parent 4780fefb73
commit 8ca961fc9d
@@ -40,6 +40,7 @@ import com.threerings.presents.dobj.AccessController;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DObjectManager;
import com.threerings.presents.dobj.RootDObjectManager;
import com.threerings.presents.server.PresentsDObjectMgr.LongRunnable;
import com.threerings.presents.server.net.ConnectionManager;
import com.threerings.crowd.server.PlaceManager;
@@ -175,18 +176,32 @@ public class PresentsServer
*/
public void run ()
{
// post a unit that will start up the connection manager when everything else in the
// dobjmgr queue is processed
_omgr.postRunnable(new Runnable() {
// wait till everything in the dobjmgr queue and invokers are processed and then start the
// connection manager
((PresentsInvoker)_invoker).postRunnableWhenEmpty(new Runnable() {
public void run () {
// start up the connection manager
_conmgr.start();
// Take as long as you like opening to the public
_omgr.postRunnable(new LongRunnable() {
public void run () {
openToThePublic();
}
});
}
});
// invoke the dobjmgr event loop
_omgr.run();
}
/**
* Opens the server for connections after the event thread is running and all the invokers are
* clear after starting up.
*/
protected void openToThePublic ()
{
log.info("Opening the gates");
_conmgr.start();
}
/**
* Queues up a request to shutdown on the event thread. This method may be safely called from
* any thread.