intarsys runtime library

de.intarsys.tools.component
Interface IReferenceCounter


public interface IReferenceCounter

An object that is aware of its referents.

The object implements a reference counting mechanism that should behave like this:

If combined with the INotificationSupport, the object MAY trigger an AttributeChangedEvent upon acquire/release. In this case the ATTR_REFERENCECOUNT should be used to indicate the attribute.

If combined with the INotificationSupport, the object MAY trigger a DestroyedEvent when the reference count reaches 0.


Field Summary
static Attribute ATTR_REFERENCECOUNT
           
 
Method Summary
 Object acquire()
          Indicate usage of the object.
 int getReferenceCount()
          The current "usage level".
 void release()
          Deprecated. use release(handle)
 void release(Object handle)
          The object is no longer needed.
 

Field Detail

ATTR_REFERENCECOUNT

static final Attribute ATTR_REFERENCECOUNT
Method Detail

acquire

Object acquire()
Indicate usage of the object. If valid, the reference count should increase and the method returns an opaque handle representing the "usage claim". This handle must be returned upon calling "release".

Returns:
An opaque usage token

getReferenceCount

int getReferenceCount()
The current "usage level". This is the number of unreleased "usage claims" via acquire.

Returns:
The current "usage level".

release

@Deprecated
void release()
Deprecated. use release(handle)

Old style release method


release

void release(Object handle)
The object is no longer needed. The reference count is decreased and the usage marked with the opaque handle is disposed.

Parameters:
handle -

intarsys runtime library

Copyright © 2012 intarsys consulting GmbH. All Rights Reserved.