All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.qt.core.QtFuture Maven / Gradle / Ivy

The newest version!
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 connect(QMetaObject.AbstractPrivateSignal3 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,c)->{ promise.reportResult(new Object[] {a,b,c}); 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.AbstractPrivateSignal4 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,c,d)->{ promise.reportResult(new Object[] {a,b,c,d}); 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.AbstractPrivateSignal5 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,c,d,e)->{ promise.reportResult(new Object[] {a,b,c,d,e}); 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.AbstractPrivateSignal6 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,c,d,e,f)->{ promise.reportResult(new Object[] {a,b,c,d,e,f}); 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.AbstractPrivateSignal7 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,c,d,e,f,g)->{ promise.reportResult(new Object[] {a,b,c,d,e,f,g}); 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.AbstractPrivateSignal8 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,c,d,e,f,g,h)->{ promise.reportResult(new Object[] {a,b,c,d,e,f,g,h}); 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.AbstractPrivateSignal9 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,c,d,e,f,g,h,i)->{ promise.reportResult(new Object[] {a,b,c,d,e,f,g,h,i}); 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 makeReadyFuture(java.util.Collection values) { QFutureInterface promise = new QFutureInterface<>(); promise.reportStarted(); promise.reportResults(values); promise.reportFinished(); return promise.future(); } @io.qt.QtUninvokable public static QFuture makeReadyFuture() { QFutureInterface promise = QFutureInterface.createVoidFutureInterface(); promise.reportStarted(); promise.reportFinished(); return promise.future(); } @io.qt.QtUninvokable public static QFuture makeExceptionalFuture(Throwable exception) { QFutureInterface promise = QFutureInterface.createVoidFutureInterface(); promise.reportStarted(); promise.reportException(exception); promise.reportFinished(); return promise.future(); } @io.qt.QtUninvokable public static QFuture> whenAny(QFuture... futures) { if(futures==null || futures.length==0) return makeReadyFuture(java.util.Collections.emptyList()); QPromise> promise = new QPromise<>(); promise.start(); java.util.concurrent.atomic.AtomicBoolean ab = new java.util.concurrent.atomic.AtomicBoolean(); for (QFuture qFuture : futures) { qFuture.then(f->{ if(ab.compareAndExchange(false, true)) { promise.addResult(f); promise.finish(); } }); } return promise.future(); } @io.qt.QtUninvokable public static QFuture> whenAny(java.util.Collection> futures) { if(futures==null || futures.size()==0) return makeReadyFuture(java.util.Collections.emptyList()); QPromise> promise = new QPromise<>(); promise.start(); java.util.concurrent.atomic.AtomicBoolean ab = new java.util.concurrent.atomic.AtomicBoolean(); for (QFuture qFuture : futures) { qFuture.then(f->{ if(ab.compareAndExchange(false, true)) { promise.addResult(f); promise.finish(); } }); } return promise.future(); } @io.qt.QtUninvokable public static QFuture>> whenAll(QFuture... futures) { if(futures==null || futures.length==0) return makeReadyFuture(java.util.Collections.emptyList()); QPromise>> promise = new QPromise<>(); promise.start(); QList> list = new QList<>(QMetaType.Type.QVariant); list.resize(futures.length); java.util.concurrent.atomic.AtomicInteger ai = new java.util.concurrent.atomic.AtomicInteger(futures.length); int i=0; for (QFuture qFuture : futures) { int _i = i++; qFuture.then(f->{ list.set(_i, f); if(ai.incrementAndGet()==0) { promise.addResult(list); promise.finish(); } }); } return promise.future(); } @io.qt.QtUninvokable public static QFuture>> whenAll(java.util.Collection> futures) { if(futures==null || futures.size()==0) return makeReadyFuture(java.util.Collections.emptyList()); QPromise>> promise = new QPromise<>(); promise.start(); QList> list = new QList<>(QMetaType.Type.QVariant); list.resize(futures.size()); java.util.concurrent.atomic.AtomicInteger ai = new java.util.concurrent.atomic.AtomicInteger(futures.size()); int i=0; for (QFuture qFuture : futures) { int _i = i++; qFuture.then(f->{ list.set(_i, f); if(ai.incrementAndGet()==0) { promise.addResult(list); promise.finish(); } }); } return promise.future(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy