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:
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user