public class GlobalRef extends java.lang.ref.WeakReference<PyObject> implements ReferenceBackend
| Modifier and Type | Field and Description |
|---|---|
protected boolean |
cleared
This boolean is set
true when the callback is processed. |
static ReferenceBackendFactory |
factory
This is a hook for JyNI to insert a native-objects-aware implementation
of ReferenceBackend.
|
| Modifier and Type | Method and Description |
|---|---|
void |
add(AbstractReference ref) |
int |
count() |
boolean |
equals(java.lang.Object o)
Allow
GlobalRefs to be used as hashtable-keys. |
AbstractReference |
find(java.lang.Class<?> cls)
Search for a reusable reference.
|
static int |
getCount(PyObject object)
Return the number of references to the specified
PyObject. |
static PyList |
getRefs(PyObject object)
Return a list of references to the specified
PyObject. |
static boolean |
hasDelayedCallbacks() |
int |
hashCode()
Allows
GlobalRef to be used as hashtable-keys. |
boolean |
isCleared() |
static ReferenceBackend |
newInstance(PyObject object)
Create a new tracked
ReferenceBackend. |
static void |
processDelayedCallbacks()
Call all callbacks that were enqueued via
delayedCallback(GlobalRef) method. |
int |
pythonHashCode()
The publicly used
hashCode, for the
AbstractReference
wrapper. |
PyList |
refs() |
void |
restore(PyObject formerReferent)
Restores this weak reference to its former referent.
|
protected ReferenceBackend |
retryFactory()
Returns null if nothing is changed.
|
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitgetpublic static ReferenceBackendFactory factory
protected boolean cleared
true when the callback is processed.
If the reference is cleared it might potentially be restored until
this boolean is set true. If weak reference restoring is activated (c.f.
gc.PRESERVE_WEAKREFS_ON_RESURRECTION), AbstractReference.get()
would block until a consistent state is reached (i.e. referent is
non-null or cleared == true).public GlobalRef(PyObject object)
public void add(AbstractReference ref)
add in interface ReferenceBackendpublic AbstractReference find(java.lang.Class<?> cls)
find in interface ReferenceBackendpublic static void processDelayedCallbacks()
delayedCallback(GlobalRef) method.delayedCallback(GlobalRef)public static boolean hasDelayedCallbacks()
public boolean isCleared()
isCleared in interface ReferenceBackendpublic int count()
count in interface ReferenceBackendpublic PyList refs()
refs in interface ReferenceBackendprotected ReferenceBackend retryFactory()
this, this
result is returned. Also, this result is then installed
in all weak-references, in the referent's JyAttribute and
in the objects-map to act as a proxy for this GlobalRef,
which will still serve as a backend for the proxy. This
method is most likely used exclusively by JyNI.public static ReferenceBackend newInstance(PyObject object)
ReferenceBackend.
If no ReferenceBackendFactory is registered, it actually
returns a GlobalRef.object - a PyObject to referenceReferenceBackendpublic void restore(PyObject formerReferent)
GlobalRef is created
and inserted into all adjacent
AbstractReferences. The
current GlobalRef is disbanded.
If the given PyObject is not the former
referent of this weak reference, an
IllegalArgumentException is thrown.restore in interface ReferenceBackendjava.lang.IllegalArgumentException - if formerReferent is not
the actual former referent.public static int getCount(PyObject object)
PyObject.object - a PyObjectpublic static PyList getRefs(PyObject object)
PyObject.public boolean equals(java.lang.Object o)
GlobalRefs to be used as hashtable-keys.equals in class java.lang.Objectpublic int hashCode()
GlobalRef to be used as hashtable-keys.hashCode in class java.lang.Objectint-valuepublic int pythonHashCode()
hashCode, for the
AbstractReference
wrapper.pythonHashCode in interface ReferenceBackendint-value