
public class RefCounted extends Object
RefCounted objects cannot be made with new. They must be
constructed with special factory methods, usually called
make(...).
| Modifier and Type | Method and Description |
|---|---|
RefCounted |
copyReference()
Create a new RefCounted object that is actually referring to the
exact same underlying native object.
|
void |
delete()
Releases any underlying native memory and marks this object
as invalid.
|
long |
getCurrentRefCount()
Return the current reference count on this object.
|
public void delete()
Normally Ferry manages when to release native memory.
In the unlikely event you want to control EXACTLY when a native
object is released, each Humble object has a delete()
method that you can use. Once you call delete(),
you must ENSURE your object is never referenced again from
that Java object -- Ferry tries to help you avoid crashes if you
accidentally use an object after deletion but on this but we
cannot offer 100% protection (specifically if another thread
is accessing that object EXACTLY when you delete() it).
public RefCounted copyReference()
public long getCurrentRefCount()
The number returned represents the value at the instant the message was called, and the value can change even before this method returns. Callers are advised not to depend on the value of this except to check that the value == 1.
If the value returned is one, and you know you have a valid reference to that object, then congratulations; you are the only person referencing that object.
Copyright © 2018 Humble Software. All rights reserved.