org.python.core.PySystemStateRef Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of jython-slim Show documentation
Show all versions of jython-slim Show documentation
Jython is an implementation of the high-level, dynamic, object-oriented
language Python written in 100% Pure Java, and seamlessly integrated with
the Java platform. It thus allows you to run Python on any Java platform.
package org.python.core;
import java.lang.ref.ReferenceQueue;
import java.lang.ref.WeakReference;
/**
* A weak reference that allows to keep track of PySystemState
* within Jython core runtime without leaking: as soon as it
* gets garbage collected, we can clear the places where we have
* associated data stored.
*/
public class PySystemStateRef extends WeakReference {
static final ReferenceQueue referenceQueue = new ReferenceQueue<>();
private ThreadState threadStateBackReference;
public PySystemStateRef(PySystemState referent, ThreadState threadState) {
super(referent, referenceQueue);
threadStateBackReference = threadState;
}
public ThreadState getThreadState() {
return threadStateBackReference;
}
}