Make it possible to have a distributed object destroyed when its last

subscriber is removed.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2602 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2003-05-22 17:23:53 +00:00
parent 8197441658
commit d76d4e89ff
4 changed files with 25 additions and 9 deletions
@@ -1,5 +1,5 @@
//
// $Id: ClientDObjectMgr.java,v 1.23 2003/04/10 17:48:42 mdb Exp $
// $Id: ClientDObjectMgr.java,v 1.24 2003/05/22 17:23:53 mdb Exp $
package com.threerings.presents.client;
@@ -106,7 +106,7 @@ public class ClientDObjectMgr
}
// inherit documentation from the interface
public void removedLastSubscriber (DObject obj)
public void removedLastSubscriber (DObject obj, boolean deathWish)
{
// if this object has a registered flush delay, don't can it just
// yet, just slip it onto the flush queue
@@ -1,5 +1,5 @@
//
// $Id: DObject.java,v 1.63 2003/04/30 22:32:04 mdb Exp $
// $Id: DObject.java,v 1.64 2003/05/22 17:23:53 mdb Exp $
package com.threerings.presents.dobj;
@@ -151,11 +151,20 @@ public class DObject implements Streamable
// that we're still active otherwise there's no need to notify
// our objmgr because we don't have one
if (--_scount == 0 && _omgr != null) {
_omgr.removedLastSubscriber(this);
_omgr.removedLastSubscriber(this, _deathWish);
}
}
}
/**
* Instructs this object to request to have a fork stuck in it when
* its last subscriber is removed.
*/
public void setDestroyOnLastSubscriberRemoved (boolean deathWish)
{
_deathWish = deathWish;
}
/**
* Adds an event listener to this object. The listener will be
* notified when any events are dispatched on this object that match
@@ -872,4 +881,8 @@ public class DObject implements Streamable
/** Whether or not our nested transaction has been cancelled. */
protected transient boolean _tcancelled;
/** Indicates whether we want to be destroyed when our last subscriber
* is removed. */
protected transient boolean _deathWish = false;
}
@@ -1,5 +1,5 @@
//
// $Id: DObjectManager.java,v 1.11 2003/03/10 18:29:54 mdb Exp $
// $Id: DObjectManager.java,v 1.12 2003/05/22 17:23:53 mdb Exp $
package com.threerings.presents.dobj;
@@ -95,5 +95,5 @@ public interface DObjectManager
* then choose to flush this object from the system or unregister from
* some upstream manager whose object it was proxying, for example.
*/
public void removedLastSubscriber (DObject obj);
public void removedLastSubscriber (DObject obj, boolean deathWish);
}
@@ -1,5 +1,5 @@
//
// $Id: PresentsDObjectMgr.java,v 1.31 2003/04/10 17:48:42 mdb Exp $
// $Id: PresentsDObjectMgr.java,v 1.32 2003/05/22 17:23:53 mdb Exp $
package com.threerings.presents.server;
@@ -105,9 +105,12 @@ public class PresentsDObjectMgr
}
// inherit documentation from the interface
public void removedLastSubscriber (DObject obj)
public void removedLastSubscriber (DObject obj, boolean deathWish)
{
// nothing to do here, our objects live forever!
// destroy the object if it so desires
if (deathWish) {
destroyObject(obj.getOid());
}
}
/**