When a DObject is destroyed, set its oid to -1 so that it knows that it
was once alive but is now gone. Catch attempts to start a transaction on a destroyed object and log them as such. Made isDestroyed() and isActive() final for wholly unfounded performance reasons. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@3045 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: DObject.java,v 1.73 2004/06/03 18:15:03 ray Exp $
|
// $Id: DObject.java,v 1.74 2004/07/03 07:16:56 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.dobj;
|
package com.threerings.presents.dobj;
|
||||||
|
|
||||||
@@ -582,11 +582,23 @@ public class DObject implements Streamable
|
|||||||
* <code>DObjectManager.createObject</code> it will be active until
|
* <code>DObjectManager.createObject</code> it will be active until
|
||||||
* such time as it is destroyed.
|
* such time as it is destroyed.
|
||||||
*/
|
*/
|
||||||
public boolean isActive ()
|
public final boolean isActive ()
|
||||||
{
|
{
|
||||||
return _omgr != null;
|
return _omgr != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns true if this object was once active but has now been
|
||||||
|
* destroyed and removed from the distributed object system.
|
||||||
|
* <em>Note:</em> this is not the opposite of {@link #isActive} which
|
||||||
|
* does not distinguish between pre-initialization and
|
||||||
|
* post-destruction.
|
||||||
|
*/
|
||||||
|
public final boolean isDestroyed ()
|
||||||
|
{
|
||||||
|
return (_oid == -1);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Don't call this function! It initializes this distributed object
|
* Don't call this function! It initializes this distributed object
|
||||||
* with the supplied distributed object manager. This is called by the
|
* with the supplied distributed object manager. This is called by the
|
||||||
@@ -691,8 +703,15 @@ public class DObject implements Streamable
|
|||||||
*/
|
*/
|
||||||
public void startTransaction ()
|
public void startTransaction ()
|
||||||
{
|
{
|
||||||
if (_tevent != null) {
|
// sanity check
|
||||||
|
if (isDestroyed()) {
|
||||||
|
String errmsg = "Refusing to start transaction on destroyed " +
|
||||||
|
"object [dobj=" + this + "]";
|
||||||
|
throw new IllegalArgumentException(errmsg);
|
||||||
|
|
||||||
|
} else if (_tevent != null) {
|
||||||
_tcount++;
|
_tcount++;
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
_tevent = new CompoundEvent(this, _omgr);
|
_tevent = new CompoundEvent(this, _omgr);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
//
|
//
|
||||||
// $Id: PresentsDObjectMgr.java,v 1.43 2004/06/29 03:22:22 mdb Exp $
|
// $Id: PresentsDObjectMgr.java,v 1.44 2004/07/03 07:16:56 mdb Exp $
|
||||||
|
|
||||||
package com.threerings.presents.server;
|
package com.threerings.presents.server;
|
||||||
|
|
||||||
@@ -400,6 +400,7 @@ public class PresentsDObjectMgr
|
|||||||
|
|
||||||
// inactivate the object
|
// inactivate the object
|
||||||
target.setManager(null);
|
target.setManager(null);
|
||||||
|
target.setOid(-1);
|
||||||
|
|
||||||
// deal with any remaining oid lists that reference this object
|
// deal with any remaining oid lists that reference this object
|
||||||
Reference[] refs = (Reference[])_refs.remove(oid);
|
Reference[] refs = (Reference[])_refs.remove(oid);
|
||||||
|
|||||||
Reference in New Issue
Block a user