public class GlobalRef extends WeakReference<PyObject> implements ReferenceBackend
Modifier and Type | Field and Description |
---|---|
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(Object o)
Allow
GlobalRef s to be used as hashtable-keys. |
AbstractReference |
find(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
{@link org.python.modules. |
PyList |
refs() |
void |
restore(PyObject formerReferent)
Restores this weak reference to its former referent.
|
clear, enqueue, get, isEnqueued
getClass, notify, notifyAll, toString, wait, wait, wait
get
public static ReferenceBackendFactory factory
public GlobalRef(PyObject object)
public void add(AbstractReference ref)
add
in interface ReferenceBackend
public AbstractReference find(Class<?> cls)
find
in interface ReferenceBackend
public static void processDelayedCallbacks()
delayedCallback(GlobalRef)
method.delayedCallback(GlobalRef)
public static boolean hasDelayedCallbacks()
public boolean isCleared()
isCleared
in interface ReferenceBackend
public int count()
count
in interface ReferenceBackend
public PyList refs()
refs
in interface ReferenceBackend
public static ReferenceBackend newInstance(PyObject object)
ReferenceBackend
.
If no ReferenceBackendFactory
is registered, it actually
returns a GlobalRef
.object
- a PyObject
to referenceReferenceBackend
public void restore(PyObject formerReferent)
GlobalRef
is created
and inserted into all adjacent
AbstractReference
s. 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 ReferenceBackend
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(Object o)
GlobalRef
s to be used as hashtable-keys.public int hashCode()
GlobalRef
to be used as hashtable-keys.public int pythonHashCode()
hashCode
, for the
AbstractReference
wrapper.pythonHashCode
in interface ReferenceBackend
int
-value