uka.karmi.dgc
Class HierarchicalDGC.Counter

java.lang.Object
  extended byuka.karmi.dgc.HierarchicalDGC.Counter
Enclosing class:
HierarchicalDGC

final class HierarchicalDGC.Counter
extends java.lang.Object

Counts remote references and prevents the local server implementation form being garbage collected by keeping a local reference to it.

Author:
Bernhard Haumacher, Christian Nester

Field Summary
private  int cnt
          The number of references that left the VM and are not yet finalized.
private  int exportId
          Export point identifier.
private  int objectId
          Identifier of the remote object this counter counts references to.
private  RemoteServerRef serverRef
          Reference to the local server implementation.
 
Constructor Summary
HierarchicalDGC.Counter(int exportId, int objectId)
           
 
Method Summary
 boolean dec()
          Decrements the counter.
 boolean equals(java.lang.Object obj)
           
 int hashCode()
           
 void inc()
          Increments the counter.
 void init(RemoteServerRef serverRef)
          Inits this counter with a server reference and sets its count to one.
 java.lang.String toString()
           
 java.lang.String toStringMembers()
           
 
Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, wait
 

Field Detail

exportId

private int exportId
Export point identifier.


objectId

private int objectId
Identifier of the remote object this counter counts references to.


cnt

private int cnt
The number of references that left the VM and are not yet finalized.


serverRef

private RemoteServerRef serverRef
Reference to the local server implementation. This reference prevents the server from being garbage collected as long as remote references to it exist.

Constructor Detail

HierarchicalDGC.Counter

public HierarchicalDGC.Counter(int exportId,
                               int objectId)
Method Detail

init

public void init(RemoteServerRef serverRef)
Inits this counter with a server reference and sets its count to one.


inc

public void inc()
Increments the counter.


dec

public boolean dec()
Decrements the counter. If count has reached zero, the RemoteServerRef.unreferenced() method of the server implementation is called.

Returns:
whether the count has reached zero.

equals

public boolean equals(java.lang.Object obj)

hashCode

public int hashCode()

toStringMembers

public java.lang.String toStringMembers()

toString

public java.lang.String toString()