io.qt.core.QFutureSynchronizer 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;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
/**
* Convenience class that simplifies QFuture synchronization
* Java wrapper for Qt class QFutureSynchronizer
*/
public final class QFutureSynchronizer
{
static {
QtJambi_LibraryUtilities.initialize();
}
/**
* See QFutureSynchronizer::QFutureSynchronizer()
*/
public QFutureSynchronizer(){
super();
}
/**
* See QFutureSynchronizer::QFutureSynchronizer(QFuture<T>)
*/
public QFutureSynchronizer(QFuture future){
super();
addFuture(future);
}
/**
* See QFutureSynchronizer::addFuture(QFuture<T>)
*/
@io.qt.QtUninvokable
public final void addFuture(QFuture future){
m_futures.add(future);
}
/**
* See QFutureSynchronizer::cancelOnWait()const
*/
@io.qt.QtUninvokable
public final boolean cancelOnWait(){
return m_cancelOnWait;
}
/**
* See QFutureSynchronizer::clearFutures()
*/
@io.qt.QtUninvokable
public final void clearFutures(){
m_futures.clear();
}
/**
* See QFutureSynchronizer::setCancelOnWait(bool)
*/
@io.qt.QtUninvokable
public final void setCancelOnWait(boolean enabled){
this.m_cancelOnWait = enabled;
}
/**
* See QFutureSynchronizer::setFuture(QFuture<T>)
*/
@io.qt.QtUninvokable
public final void setFuture(QFuture future){
waitForFinished();
m_futures.clear();
addFuture(future);
}
/**
* See QFutureSynchronizer::waitForFinished()const
*/
@io.qt.QtUninvokable
public final void waitForFinished(){
if (m_cancelOnWait) {
for (int i = 0; i < m_futures.size(); ++i) {
m_futures.get(i).cancel();
}
}
for (int i = 0; i < m_futures.size(); ++i) {
m_futures.get(i).waitForFinished();
}
}
/**
* See QFutureSynchronizer::futures()const
*/
@io.qt.QtUninvokable
public final List> futures() {
return Collections.unmodifiableList(m_futures);
}
private final List> m_futures = new ArrayList<>();
private boolean m_cancelOnWait;
}