Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## com.trolltech.qt.core
Class QFutureSynchronizer<T>

    java.lang.Object
      com.trolltech.qt.QSignalEmitter
          com.trolltech.qt.QtJambiObject
              com.trolltech.qt.core.QFutureSynchronizer<T>

All Implemented Interfaces:
  QtJambiInterface

    public class QFutureSynchronizer<T>

extends QtJambiObject

The `QFutureSynchronizer` class is a convenience class that simplifies `QFuture` synchronization. `QFutureSynchronizer` is a template class that simplifies synchronization of one or more `QFuture` objects. Futures are added using the `addFuture()` or `setFuture()` functions. The `futures()` function returns a list of futures. Use `clearFutures()` to remove all futures from the `QFutureSynchronizer`.

The `waitForFinished()` function waits for all futures to finish. The destructor of `QFutureSynchronizer` calls `waitForFinished()`, providing an easy way to ensure that all futures have finished before returning from a function:
The following code example is written in c++.

        void someFunction()
        {
            QFutureSynchronizer<void> synchronizer;

            ...

            synchronizer.addFuture(QtConcurrent::run(anotherFunction));
            synchronizer.addFuture(QtConcurrent::map(list, mapFunction));

            return; // QFutureSynchronizer waits for all futures to finish
        }

The behavior of `waitForFinished()` can be changed using the `setCancelOnWait()` function. Calling `setCancelOnWait`(true) will cause `waitForFinished()` to cancel all futures before waiting for them to finish. You can query the status of the cancel-on-wait feature using the `cancelOnWait()` function.

See also:
  `QFuture`, `QFutureWatcher`, and Qt Concurrent.

Nested Class Summary

Nested classes/interfaces inherited from class com.trolltech.qt.QtJambiObject
`QtJambiObject.QPrivateConstructor`

Nested classes/interfaces inherited from class com.trolltech.qt.QSignalEmitter
`QSignalEmitter.AbstractSignal, QSignalEmitter.Signal0, QSignalEmitter.Signal1<A>, QSignalEmitter.Signal2<A,B>, QSignalEmitter.Signal3<A,B,C>, QSignalEmitter.Signal4<A,B,C,D>, QSignalEmitter.Signal5<A,B,C,D,E>, QSignalEmitter.Signal6<A,B,C,D,E,F>, QSignalEmitter.Signal7<A,B,C,D,E,F,G>, QSignalEmitter.Signal8<A,B,C,D,E,F,G,H>, QSignalEmitter.Signal9<A,B,C,D,E,F,G,H,I>`

Constructor Summary
`` | `QFutureSynchronizer()` Constructs a `QFutureSynchronizer`.
`` | `QFutureSynchronizer(QFuture<T> future)` Constructs a `QFutureSynchronizer` and begins watching `future` by calling `addFuture()`.
`protected` | `QFutureSynchronizer(QtJambiObject.QPrivateConstructor p)` This method is internal to Qt Jambi.

Method Summary
`void` | `addFuture(QFuture<T> future)` Adds `future` to the list of managed futures.
`boolean` | `cancelOnWait()` Returns true if the cancel-on-wait feature is enabled; otherwise returns false.
`void` | `clearFutures()` Removes all managed futures from this `QFutureSynchronizer`.
`static QFutureSynchronizer` | `fromNativePointer(QNativePointer nativePointer)` This method returns the QFutureSynchronizer instance pointed to by `nativePointer`.
`java.util.List<QFuture<T>>` | `futures()` Returns a list of all managed futures.
`void` | `setCancelOnWait(boolean enabled)` Enables or disables the cancel-on-wait feature based on the `enabled` argument.
`void` | `setFuture(QFuture<T> future)` Sets `future` to be the only future managed by this `QFutureSynchronizer`.
`void` | `waitForFinished()` Waits for all futures to finish.

Methods inherited from class com.trolltech.qt.QtJambiObject
`disableGarbageCollection, dispose, disposed, equals, finalize, nativeId, nativePointer, reassignNativeResources, reenableGarbageCollection, setJavaOwnership, tr, tr, tr`

Methods inherited from class com.trolltech.qt.QSignalEmitter
`__qt_signalInitialization, blockSignals, disconnect, disconnect, signalsBlocked, signalSender, thread`

Methods inherited from class java.lang.Object
`clone, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### QFutureSynchronizer

    public QFutureSynchronizer()

  Constructs a `QFutureSynchronizer`.

### QFutureSynchronizer

    public QFutureSynchronizer(QFuture<T> future)

  Constructs a `QFutureSynchronizer` and begins watching `future` by calling `addFuture()`.

See also:
  `addFuture()`.

### QFutureSynchronizer

    protected QFutureSynchronizer(QtJambiObject.QPrivateConstructor p)

  This method is internal to Qt Jambi.

Method Detail

### addFuture

    public final void addFuture(QFuture<T> future)

  Adds `future` to the list of managed futures.

See also:
  `futures()`.

### cancelOnWait

    public final boolean cancelOnWait()

  Returns true if the cancel-on-wait feature is enabled; otherwise returns false. If cancel-on-wait is enabled, the `waitForFinished()` function will cancel all futures before waiting for them to finish.

See also:
  `setCancelOnWait()`, and `waitForFinished()`.

### clearFutures

    public final void clearFutures()

  Removes all managed futures from this `QFutureSynchronizer`.

See also:
  `addFuture()`, and `setFuture()`.

### setCancelOnWait

    public final void setCancelOnWait(boolean enabled)

  Enables or disables the cancel-on-wait feature based on the `enabled` argument. If `enabled` is true, the `waitForFinished()` function will cancel all futures before waiting for them to finish.

See also:
  `cancelOnWait()`, and `waitForFinished()`.

### setFuture

    public final void setFuture(QFuture<T> future)

  Sets `future` to be the only future managed by this `QFutureSynchronizer`. This is a convenience function that calls `waitForFinished()`, then `clearFutures()`, and finally passes `future` to `addFuture()`.

See also:
  `addFuture()`, `waitForFinished()`, and `clearFutures()`.

### waitForFinished

    public final void waitForFinished()

  Waits for all futures to finish. If `cancelOnWait()` returns true, each future is canceled before waiting for them to finish.

See also:
  `cancelOnWait()`, and `setCancelOnWait()`.

### fromNativePointer

    public static QFutureSynchronizer fromNativePointer(QNativePointer nativePointer)

  This method returns the QFutureSynchronizer instance pointed to by `nativePointer`.

### futures

    public final java.util.List<QFuture<T>> futures()

  Returns a list of all managed futures.

See also:
  `addFuture()`, and `setFuture()`.

Overview | Package | Class | Tree | Deprecated | Index | Help
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD