io.qt.core.QThread Maven / Gradle / Ivy
Show all versions of qtjambi Show documentation
package io.qt.core;
import io.qt.*;
/**
* Platform-independent way to manage threads
* Java wrapper for Qt class QThread
*/
public class QThread extends io.qt.core.QObject
{
@QtPropertyMember(enabled=false)
private Object __rcEventDispatcher = null;
/**
* This variable stores the meta-object for the class.
*/
public static final io.qt.core.@NonNull QMetaObject staticMetaObject = io.qt.core.QMetaObject.forType(QThread.class);
/**
* Java wrapper for Qt enum QThread::Priority
*/
@QtUnlistedEnum
public enum Priority implements QtEnumerator {
/**
* Representing QThread:: IdlePriority
*/
IdlePriority(0),
/**
* Representing QThread:: LowestPriority
*/
LowestPriority(1),
/**
* Representing QThread:: LowPriority
*/
LowPriority(2),
/**
* Representing QThread:: NormalPriority
*/
NormalPriority(3),
/**
* Representing QThread:: HighPriority
*/
HighPriority(4),
/**
* Representing QThread:: HighestPriority
*/
HighestPriority(5),
/**
* Representing QThread:: TimeCriticalPriority
*/
TimeCriticalPriority(6),
/**
* Representing QThread:: InheritPriority
*/
InheritPriority(7);
static {
QtJambi_LibraryUtilities.initialize();
}
private Priority(int value) {
this.value = value;
}
/**
* {@inheritDoc}
*/
public int value() {
return value;
}
/**
* Returns the corresponding enum entry for the given value.
* @param value
* @return enum entry
*/
public static @NonNull Priority resolve(int value) {
switch (value) {
case 0: return IdlePriority;
case 1: return LowestPriority;
case 2: return LowPriority;
case 3: return NormalPriority;
case 4: return HighPriority;
case 5: return HighestPriority;
case 6: return TimeCriticalPriority;
case 7: return InheritPriority;
default: throw new QNoSuchEnumValueException(value);
}
}
private final int value;
}
/**
*
*/
public final @NonNull PrivateSignal0 finished = new PrivateSignal0();
/**
*
*/
public final @NonNull PrivateSignal0 started = new PrivateSignal0();
/**
* See QThread:: QThread(QObject*)
*/
public QThread(io.qt.core.@Nullable QObject parent){
super((QPrivateConstructor)null);
initialize_native(this, parent);
initialize(null);
}
private native static void initialize_native(QThread instance, io.qt.core.QObject parent);
/**
* See QThread:: eventDispatcher()const
*/
@QtUninvokable
public final io.qt.core.@Nullable QAbstractEventDispatcher eventDispatcher(){
return eventDispatcher_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native io.qt.core.QAbstractEventDispatcher eventDispatcher_native_constfct(long __this__nativeId);
/**
* See QThread:: exec()
*/
@QtUninvokable
protected final int exec(){
return exec_native(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native int exec_native(long __this__nativeId);
/**
*
*/
public final void exit(int retcode){
exit_native_int(QtJambi_LibraryUtilities.internal.nativeId(this), retcode);
}
private native void exit_native_int(long __this__nativeId, int retcode);
/**
* See QThread:: isFinished()const
*/
@QtUninvokable
public final boolean isFinished(){
return isFinished_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native boolean isFinished_native_constfct(long __this__nativeId);
/**
* See QThread:: isInterruptionRequested()const
*/
@QtUninvokable
public final boolean isInterruptionRequested(){
return isInterruptionRequested_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native boolean isInterruptionRequested_native_constfct(long __this__nativeId);
/**
*
*/
@QtUninvokable
public final boolean isRunning(){
return isRunning_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native boolean isRunning_native_constfct(long __this__nativeId);
/**
*
*/
@QtUninvokable
public final int loopLevel(){
return loopLevel_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native int loopLevel_native_constfct(long __this__nativeId);
/**
*
*/
@QtUninvokable
public final io.qt.core.QThread.@NonNull Priority priority(){
return io.qt.core.QThread.Priority.resolve(priority_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this)));
}
@QtUninvokable
private native int priority_native_constfct(long __this__nativeId);
/**
* See QThread:: quit()
*/
public final void quit(){
quit_native(QtJambi_LibraryUtilities.internal.nativeId(this));
}
private native void quit_native(long __this__nativeId);
/**
* See QThread:: requestInterruption()
*/
@QtUninvokable
public final void requestInterruption(){
requestInterruption_native(QtJambi_LibraryUtilities.internal.nativeId(this));
Thread t = javaThread();
if(t!=null)
t.interrupt();
}
@QtUninvokable
private native void requestInterruption_native(long __this__nativeId);
/**
* See QThread:: setEventDispatcher(QAbstractEventDispatcher*)
*/
@QtUninvokable
public final void setEventDispatcher(io.qt.core.@Nullable QAbstractEventDispatcher eventDispatcher){
setEventDispatcher_native_QAbstractEventDispatcher_ptr(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.checkedNativeId(eventDispatcher));
__rcEventDispatcher = eventDispatcher;
}
@QtUninvokable
private native void setEventDispatcher_native_QAbstractEventDispatcher_ptr(long __this__nativeId, long eventDispatcher);
/**
* See QThread:: setPriority(QThread::Priority)
*/
@QtUninvokable
public final void setPriority(io.qt.core.QThread.@NonNull Priority priority){
setPriority_native_QThread_Priority(QtJambi_LibraryUtilities.internal.nativeId(this), priority.value());
}
@QtUninvokable
private native void setPriority_native_QThread_Priority(long __this__nativeId, int priority);
/**
* See QThread:: setStackSize(uint)
*/
@QtUninvokable
public final void setStackSize(int stackSize){
setStackSize_native_uint(QtJambi_LibraryUtilities.internal.nativeId(this), stackSize);
}
@QtUninvokable
private native void setStackSize_native_uint(long __this__nativeId, int stackSize);
/**
*
*/
@QtUninvokable
public final int stackSize(){
return stackSize_native_constfct(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native int stackSize_native_constfct(long __this__nativeId);
/**
* See QThread:: start(QThread::Priority)
*/
public final void start(io.qt.core.QThread.@NonNull Priority arg__1){
start_native_QThread_Priority(QtJambi_LibraryUtilities.internal.nativeId(this), arg__1.value());
}
private native void start_native_QThread_Priority(long __this__nativeId, int arg__1);
/**
*
*/
public final void terminate(){
terminate_native(QtJambi_LibraryUtilities.internal.nativeId(this));
}
private native void terminate_native(long __this__nativeId);
/**
* See QThread:: wait(QDeadlineTimer)
*/
@QtUninvokable
public final boolean join(io.qt.core.@NonNull QDeadlineTimer deadline){
return join_native_QDeadlineTimer(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.checkedNativeId(deadline));
}
@QtUninvokable
private native boolean join_native_QDeadlineTimer(long __this__nativeId, long deadline);
/**
*
*/
@QtUninvokable
public final boolean join(int time){
return join_native_unsigned_long(QtJambi_LibraryUtilities.internal.nativeId(this), time);
}
@QtUninvokable
private native boolean join_native_unsigned_long(long __this__nativeId, int time);
/**
*
*/
@QtUninvokable
@Override
public boolean event(io.qt.core.@Nullable QEvent event){
return event_native_QEvent_ptr(QtJambi_LibraryUtilities.internal.nativeId(this), QtJambi_LibraryUtilities.internal.checkedNativeId(event));
}
@QtUninvokable
private native boolean event_native_QEvent_ptr(long __this__nativeId, long event);
/**
* See QThread:: run()
*/
@QtUninvokable
protected void run(){
run_native(QtJambi_LibraryUtilities.internal.nativeId(this));
}
@QtUninvokable
private native void run_native(long __this__nativeId);
/**
*
*/
public native static io.qt.core.@Nullable QThread currentThread();
/**
* See QThread:: currentThreadId()
*/
public native static long currentThreadId();
/**
* See QThread:: idealThreadCount()
*/
public native static int idealThreadCount();
/**
*
*/
public native static void msleep(int arg__1);
/**
* See QThread:: setTerminationEnabled(bool)
*/
protected native static void setTerminationEnabled(boolean enabled);
/**
* See QThread:: sleep(std::chrono::nanoseconds)
*/
public native static void sleep(java.time.temporal.@NonNull TemporalAmount nsec);
/**
*
*/
public native static void sleep(int arg__1);
/**
*
*/
public native static void usleep(int arg__1);
/**
* See QThread:: yieldCurrentThread()
*/
public native static void yieldCurrentThread();
/**
* Constructor for internal use only.
* @param p expected to be null
.
* @hidden
*/
@NativeAccess
protected QThread(QPrivateConstructor p) { super(p); }
/**
* Constructor for internal use only.
* It is not allowed to call the declarative constructor from inside Java.
* @hidden
*/
@NativeAccess
protected QThread(QDeclarativeConstructor constructor) {
super((QPrivateConstructor)null);
initialize_native(this, constructor);
}
@QtUninvokable
private static native void initialize_native(QThread instance, QDeclarativeConstructor constructor);
static native void initialize();
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(ThreadGroup group, String name, long stackSize, QObject parent) {
super((QPrivateConstructor)null);
initialize_native(this, parent);
initialize(group);
if(name!=null)
setName(name);
if(stackSize>=0 && stackSize <= 0x0ffffffffL)
setStackSize( (int)(stackSize & 0x0ffffffffL) );
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(Runnable)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable) {
return create(null, runnable, null, -1, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(Runnable)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, @Nullable QObject parent) {
return create(null, runnable, null, -1, parent);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, long stackSize) {
return create(null, runnable, null, stackSize, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, long stackSize, @Nullable QObject parent) {
return create(null, runnable, null, stackSize, parent);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable, long stackSize) {
return create(group, runnable, null, stackSize, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable, long stackSize, @Nullable QObject parent) {
return create(group, runnable, null, stackSize, parent);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable, @Nullable String name) {
return create(group, runnable, name, -1, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable, @Nullable String name, @Nullable QObject parent) {
return create(group, runnable, name, -1, parent);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable, @Nullable String name, long stackSize) {
return create(group, runnable, name, stackSize, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(Runnable, String)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, @Nullable String name, long stackSize, @Nullable QObject parent) {
return create(null, runnable, name, stackSize, parent);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(Runnable, String)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, @Nullable String name, long stackSize) {
return create(null, runnable, name, stackSize, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(Runnable, String)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, @Nullable String name, @Nullable QObject parent) {
return create(null, runnable, name, -1, parent);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(Runnable, String)
*/
public static @NonNull QThread create(@StrictNonNull Runnable runnable, @Nullable String name) {
return create(null, runnable, name, -1, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable) {
return create(group, runnable, null, -1, null);
}
/**
* See QThread::create(Function, Args...)
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public static @NonNull QThread create(ThreadGroup group, @StrictNonNull Runnable runnable, @Nullable String name, long stackSize, @Nullable QObject parent) {
return new Runner(group, runnable, name, stackSize, parent);
}
private final static class Runner extends QThread{
Runner(ThreadGroup group, Runnable runnable, String name, long stackSize, QObject parent) {
super(group, name, stackSize, parent);
this.runnable = runnable;
}
private final Runnable runnable;
@Override
protected void run() {
if(runnable!=null){
runnable.run();
}
}
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable String name) {
this(null, name, -1, null);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable ThreadGroup group) {
this(group, null, -1, null);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable String name, @Nullable QObject parent) {
this(null, name, -1, parent);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(ThreadGroup group, QObject parent) {
this(group, null, -1, parent);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable String name, long stackSize) {
this(null, name, stackSize, null);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable ThreadGroup group, long stackSize) {
this(group, null, stackSize, null);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable String name, long stackSize, @Nullable QObject parent) {
this(null, name, stackSize, parent);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable ThreadGroup group, long stackSize, @Nullable QObject parent) {
this(group, null, stackSize, parent);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable ThreadGroup group, @Nullable String name, long stackSize) {
this(group, name, stackSize, null);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable ThreadGroup group, @Nullable String name, QObject parent) {
this(group, name, -1, parent);
}
/**
* @see Thread#Thread(ThreadGroup, Runnable, String, long)
*/
public QThread(@Nullable ThreadGroup group, @Nullable String name) {
this(group, name, -1, null);
}
private void initialize(ThreadGroup group) {
if(group==null)
group = Thread.currentThread().getThreadGroup();
__qt_initialize(group);
}
/**
* @see Thread#getThreadGroup()
*/
public final @Nullable ThreadGroup getThreadGroup() {
if(javaThread!=null) {
return javaThread.getThreadGroup();
}
return __qt_getThreadGroup();
}
private native ThreadGroup __qt_getThreadGroup();
/**
* @see Thread#setName(String)
*/
public void setName(@Nullable String name) {
if(!isRunning() && javaThread==null)
__qt_setName(name);
}
private native void __qt_setName(String name);
/**
* @see Thread#getName()
*/
public final @Nullable String getName() {
if(javaThread!=null) {
return javaThread.getName();
}
return __qt_getName();
}
private native String __qt_getName();
/**
* @see Thread#setDaemon(boolean)
*/
public void setDaemon(boolean daemon) {
if(!isRunning() && javaThread==null)
__qt_setDaemon(daemon);
}
private native void __qt_setDaemon(boolean daemon);
/**
* @see Thread#isDaemon()
*/
public final boolean isDaemon() {
if(javaThread!=null) {
return javaThread.isDaemon();
}
return __qt_isDaemon();
}
private native boolean __qt_isDaemon();
/**
* @see Thread#setUncaughtExceptionHandler(java.lang.Thread.UncaughtExceptionHandler)
*/
public void setUncaughtExceptionHandler(Thread.@Nullable UncaughtExceptionHandler handler) {
if(javaThread!=null) {
javaThread.setUncaughtExceptionHandler(handler);
}else {
__qt_setUncaughtExceptionHandler(handler);
}
}
private native void __qt_setUncaughtExceptionHandler(Thread.UncaughtExceptionHandler handler);
/**
* @see Thread#getUncaughtExceptionHandler()
*/
public final Thread.@Nullable UncaughtExceptionHandler getUncaughtExceptionHandler() {
if(javaThread!=null) {
return javaThread.getUncaughtExceptionHandler();
}
return __qt_getUncaughtExceptionHandler();
}
private native Thread.UncaughtExceptionHandler __qt_getUncaughtExceptionHandler();
/**
* Sets the class loader of this thread
* @see Thread#setContextClassLoader(ClassLoader)
*/
public void setContextClassLoader(@Nullable ClassLoader cl) {
if(javaThread!=null) {
javaThread.setContextClassLoader(cl);
}else {
__qt_setContextClassLoader(cl);
}
}
private native void __qt_setContextClassLoader(ClassLoader cl);
/**
* Returns the class loader of this thread
* @see Thread#getContextClassLoader()
*/
public final @Nullable ClassLoader getContextClassLoader() {
if(javaThread!=null) {
return javaThread.getContextClassLoader();
}
return __qt_getContextClassLoader();
}
private native ClassLoader __qt_getContextClassLoader();
private native void __qt_initialize(ThreadGroup group);
private final Thread javaThread = null;
/**
* Returns the {@link Thread} instance representing this {@link QThread}.
*/
public final @Nullable Thread javaThread() { return javaThread==null ? __qt_javaThread() : javaThread; }
private native Thread __qt_javaThread();
public static native @Nullable QThread thread(@NonNull Thread thread);
/**
* Returns true if thread is running.
* @see Thread#isAlive()
*/
public final boolean isAlive() {
return isRunning();
}
/**
* Returns true if interruption is requested.
* @see Thread#isInterrupted()
*/
public final boolean isInterrupted() {
if(javaThread!=null && javaThread.isInterrupted())
return true;
return isInterruptionRequested();
}
/**
* Checks if current thread has been interrupted and clear interruption state.
* @see Thread#interrupted()
*/
public static boolean interrupted() {
return Thread.interrupted();
}
/**
* Interrupts the current thread.
* @see Thread#interrupt()
*/
public final void interrupt() {
requestInterruption();
}
/**
* Overloaded constructor for {@link #QThread(io.qt.core.QObject)}
* with parent = null
.
*/
public QThread() {
this((io.qt.core.QObject)null);
}
/**
* Overloaded function for {@link #exit(int)}
* with retcode = 0
.
*/
public final void exit() {
exit((int)0);
}
/**
* Overloaded function for {@link #start(io.qt.core.QThread.Priority)}
* with arg__1 = io.qt.core.QThread.Priority.InheritPriority
.
*/
public final void start() {
start(io.qt.core.QThread.Priority.InheritPriority);
}
/**
* Overloaded function for {@link #join(io.qt.core.QDeadlineTimer)}
* with deadline = new QDeadlineTimer(QDeadlineTimer.ForeverConstant.Forever)
.
*/
@QtUninvokable
public final boolean join() {
return join(new QDeadlineTimer(QDeadlineTimer.ForeverConstant.Forever));
}
/**
* Overloaded function for {@link #join(io.qt.core.QDeadlineTimer)}.
*/
@QtUninvokable
public final boolean join(io.qt.core.QDeadlineTimer.@NonNull ForeverConstant deadline) {
return join(new io.qt.core.QDeadlineTimer(deadline));
}
/**
* Overloaded function for {@link #setTerminationEnabled(boolean)}
* with enabled = true
.
*/
protected static void setTerminationEnabled() {
setTerminationEnabled((boolean)true);
}
}