Replaced old wacked-in-head system with proper reference counting for

client objects.


git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@1989 542714f4-19e9-0310-aa3c-eee0fc999fb1
This commit is contained in:
Michael Bayne
2002-11-26 02:14:25 +00:00
parent 7b6f4893a2
commit 371ca60bf5
5 changed files with 92 additions and 81 deletions
@@ -1,11 +1,13 @@
//
// $Id: ClientObject.dobj,v 1.2 2002/09/19 23:36:59 mdb Exp $
// $Id: ClientObject.dobj,v 1.3 2002/11/26 02:14:24 mdb Exp $
package com.threerings.presents.data;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DSet;
import com.threerings.presents.Log;
/**
* Every client in the system has an associated client object to which
* only they subscribe. The client object can be used to deliver messages
@@ -29,4 +31,32 @@ public class ClientObject extends DObject
{
return "(" + getOid() + ")";
}
/**
* Used for reference counting client objects, adds a reference to
* this object.
*/
public synchronized void reference ()
{
_references++;
// Log.info("Incremented references [who=" + who() +
// ", refs=" + _references + "].");
}
/**
* Used for reference counting client objects, releases a reference to
* this object.
*
* @return true if the object has remaining references, false
* otherwise.
*/
public synchronized boolean release ()
{
// Log.info("Decremented references [who=" + who() +
// ", refs=" + (_references-1) + "].");
return (--_references > 0);
}
/** Used to reference count resolved client objects. */
protected transient int _references;
}
@@ -1,11 +1,13 @@
//
// $Id: ClientObject.java,v 1.4 2002/09/19 23:36:59 mdb Exp $
// $Id: ClientObject.java,v 1.5 2002/11/26 02:14:24 mdb Exp $
package com.threerings.presents.data;
import com.threerings.presents.dobj.DObject;
import com.threerings.presents.dobj.DSet;
import com.threerings.presents.Log;
/**
* Every client in the system has an associated client object to which
* only they subscribe. The client object can be used to deliver messages
@@ -33,6 +35,34 @@ public class ClientObject extends DObject
return "(" + getOid() + ")";
}
/**
* Used for reference counting client objects, adds a reference to
* this object.
*/
public synchronized void reference ()
{
_references++;
// Log.info("Incremented references [who=" + who() +
// ", refs=" + _references + "].");
}
/**
* Used for reference counting client objects, releases a reference to
* this object.
*
* @return true if the object has remaining references, false
* otherwise.
*/
public synchronized boolean release ()
{
// Log.info("Decremented references [who=" + who() +
// ", refs=" + (_references-1) + "].");
return (--_references > 0);
}
/** Used to reference count resolved client objects. */
protected transient int _references;
/**
* Requests that the specified entry be added to the
* <code>receivers</code> set. The set will not change until the event is