 import com.threerings.presents.dobj.Subscriber;
 
 /**
- * A class that safely handles the asynchronous subscription to a
- * distributed object when it is not know if the subscription will
- * complete before the subscriber decides they no longer wish to be
+ * A class that safely handles the asynchronous subscription to a distributed object when it is not
+ * know if the subscription will complete before the subscriber decides they no longer wish to be
  * subscribed.
  */
 public class SafeSubscriber implements Subscriber
 {
-    private static const log :Log = Log.getLog(SafeSubscriber);
-    /**
-     * Creates a safe subscriber for the specified distributed object
-     * which will interact with the specified subscriber.
+    /**
+     * Creates a safe subscriber for the specified distributed object which will interact with the
+     * specified subscriber.
      */
     public function SafeSubscriber (oid :int, subscriber :Subscriber)
     {
         // make sure they're not fucking us around
         if (oid <= 0) {
-            throw new ArgumentError(
-                "Invalid oid provided to safesub [oid=" + oid + "]");
+            throw new ArgumentError("Invalid oid provided to safesub [oid=" + oid + "]");
         }
         if (subscriber == null) {
-            throw new ArgumentError(
-                "Null subscriber provided to safesub [oid=" + oid + "]");
+            throw new ArgumentError("Null subscriber provided to safesub [oid=" + oid + "]");
         }
 
         _oid = oid;

    public function subscribe (omgr :DObjectManager) :void
    {
        if (_active) {
            log.warning("Active safesub asked to resubscribe " + this + ".");
            return;
        }

        // note that we are now again in the "wishing to be subscribed" state
        _active = true;

        // make sure we dont have an object reference (which should be
        // logically impossible)
        if (_object != null) {
            log.warning("Incroyable! A safesub has an object and was " +
                        "non-active!? " + this + ".");
            // make do in the face of insanity
            _subscriber.objectAvailable(_object);
            return;
        }

        if (_pending) {
            // we were previously asked to subscribe, then they asked to
            // unsubscribe and now they've asked to subscribe again, all
            // before the original subscription even completed; we need do
            // nothing here except as the original subscription request
            // will eventually come through and all will be well
            return;
        }

        // we're not pending and we just became active, that means we need
        // to request to subscribe to our object
        _pending = true;
        omgr.subscribeToObject(_oid, this);
    }

    /**
     * Terminates the object subscription. If the initial subscription has
     * not yet completed, the desire to terminate will be noted and the
     * subscription will be terminated as soon as it completes.
     */
    public function unsubscribe (omgr :DObjectManager) :void
    {
        if (!_active) {
            // we may be non-active and have no object which could mean
            // that subscription failed; in which case we don't want to
            // complain about anything, just quietly ignore the
            // unsubscribe request
            if (_object == null && !_pending) {
                return;
            }
            log.warning("Inactive safesub asked to unsubscribe " + this + ".");
            Log.dumpStack();
        }


    {
        // make sure life is not too cruel
        if (_object != null) {
            log.warning("Our object came available but we've already got one!? " + this);
            // go ahead and pitch the old one, God knows what's going on
            _object = null;
        }
        if (!_pending) {
            log.warning("Our object came available but we're not pending!? " + this);
            // go with our badselves, it's the only way
        }

