io.qt.core.QtFuture Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of qtjambi Show documentation
Show all versions of qtjambi Show documentation
QtJambi base module containing QtCore, QtGui and QtWidgets.
package io.qt.core;
/**
* Contains miscellaneous identifiers used by the QFuture class
* Java wrapper for Qt class QtFuture
*/
public final class QtFuture
{
static {
QtJambi_LibraryUtilities.initialize();
}
private QtFuture() throws java.lang.InstantiationError { throw new java.lang.InstantiationError("Cannot instantiate namespace QtFuture."); }
/**
* Java wrapper for Qt enum QtFuture::Launch
*/
public enum Launch implements io.qt.QtEnumerator {
Sync(0),
Async(1),
Inherit(2);
private Launch(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 Launch resolve(int value) {
switch (value) {
case 0: return Sync;
case 1: return Async;
case 2: return Inherit;
default: throw new io.qt.QNoSuchEnumValueException(value);
}
}
private final int value;
}
@io.qt.QtUninvokable
public static QFuture connect(QMetaObject.AbstractPrivateSignal0 signal) {
if(signal.containingObject() instanceof QObject) {
QObject sender = (QObject)signal.containingObject();
QFutureInterface promise = QFutureInterface.createVoidFutureInterface();
promise.reportStarted();
QMetaObject.Connection[] connections = {null, null};
connections[0] = signal.connect(()->{
promise.reportFinished();
QObject.disconnect(connections[0]);
QObject.disconnect(connections[1]);
});
connections[1] = sender.destroyed.connect(()->{
promise.reportCanceled();
promise.reportFinished();
QObject.disconnect(connections[0]);
QObject.disconnect(connections[1]);
});
return promise.future();
}
return null;
}
@io.qt.QtUninvokable
public static QFuture connect(QMetaObject.AbstractPrivateSignal1 signal) {
if(signal.containingObject() instanceof QObject) {
QObject sender = (QObject)signal.containingObject();
QFutureInterface promise = new QFutureInterface<>();
promise.reportStarted();
QMetaObject.Connection[] connections = {null, null};
connections[0] = signal.connect(value->{
promise.reportResult(value);
promise.reportFinished();
QObject.disconnect(connections[0]);
QObject.disconnect(connections[1]);
});
connections[1] = sender.destroyed.connect(()->{
promise.reportCanceled();
promise.reportFinished();
QObject.disconnect(connections[0]);
QObject.disconnect(connections[1]);
});
return promise.future();
}
return null;
}
@io.qt.QtUninvokable
public static QFuture> connect(QMetaObject.AbstractPrivateSignal2 signal) {
if(signal.containingObject() instanceof QObject) {
QObject sender = (QObject)signal.containingObject();
QFutureInterface> promise = new QFutureInterface<>();
promise.reportStarted();
QMetaObject.Connection[] connections = {null, null};
connections[0] = signal.connect((a,b)->{
promise.reportResult(new QPair<>(a,b));
promise.reportFinished();
QObject.disconnect(connections[0]);
QObject.disconnect(connections[1]);
});
connections[1] = sender.destroyed.connect(()->{
promise.reportCanceled();
promise.reportFinished();
QObject.disconnect(connections[0]);
QObject.disconnect(connections[1]);
});
return promise.future();
}
return null;
}
@io.qt.QtUninvokable
public static QFuture
© 2015 - 2025 Weber Informatics LLC | Privacy Policy