Struct qt_core::QFutureOf

source ·
#[repr(C)]
pub struct QFutureOf { /* private fields */ }
Expand description

The QFuture class represents the result of an asynchronous computation.

C++ class: QFuture<void>.

C++ documentation:

The QFuture class represents the result of an asynchronous computation.

To start a computation, use one of the APIs in the Qt Concurrent framework.

QFuture allows threads to be synchronized against one or more results which will be ready at a later point in time. The result can be of any type that has a default constructor and a copy constructor. If a result is not available at the time of calling the result(), resultAt(), or results() functions, QFuture will wait until the result becomes available. You can use the isResultReadyAt() function to determine if a result is ready or not. For QFuture objects that report more than one result, the resultCount() function returns the number of continuous results. This means that it is always safe to iterate through the results from 0 to resultCount().

QFuture provides a Java-style iterator (QFutureIterator) and an STL-style iterator (QFuture::const_iterator). Using these iterators is another way to access results in the future.

QFuture also offers ways to interact with a runnning computation. For instance, the computation can be canceled with the cancel() function. To pause the computation, use the setPaused() function or one of the pause(), resume(), or togglePaused() convenience functions. Be aware that not all asynchronous computations can be canceled or paused. For example, the future returned by QtConcurrent::run() cannot be canceled; but the future returned by QtConcurrent::mappedReduced() can.

Progress information is provided by the progressValue(), progressMinimum(), progressMaximum(), and progressText() functions. The waitForFinished() function causes the calling thread to block and wait for the computation to finish, ensuring that all results are available.

The state of the computation represented by a QFuture can be queried using the isCanceled(), isStarted(), isFinished(), isRunning(), or isPaused() functions.

QFuture is a lightweight reference counted class that can be passed by value.

QFuture<void> is specialized to not contain any of the result fetching functions. Any QFuture<T> can be assigned or copied into a QFuture<void> as well. This is useful if only status or progress information is needed - not the actual result data.

To interact with running tasks using signals and slots, use QFutureWatcher.

Implementations§

source§

impl QFutureOf

source

pub unsafe fn cancel(&self)

Cancels the asynchronous computation represented by this future. Note that the cancelation is asynchronous. Use waitForFinished() after calling cancel() when you need synchronous cancelation.

Calls C++ function: void QFuture<void>::cancel().

C++ documentation:

Cancels the asynchronous computation represented by this future. Note that the cancelation is asynchronous. Use waitForFinished() after calling cancel() when you need synchronous cancelation.

Results currently available may still be accessed on a canceled future, but new results will not become available after calling this function. Any QFutureWatcher object that is watching this future will not deliver progress and result ready signals on a canceled future.

Be aware that not all asynchronous computations can be canceled. For example, the future returned by QtConcurrent::run() cannot be canceled; but the future returned by QtConcurrent::mappedReduced() can.

source

pub unsafe fn copy_from( &self, other: impl CastInto<Ref<QFutureOf>> ) -> Ref<QFutureOf>

The QFuture class represents the result of an asynchronous computation.

Calls C++ function: QFuture<void>& QFuture<void>::operator=(const QFuture<void>& other).

C++ documentation:

The QFuture class represents the result of an asynchronous computation.

To start a computation, use one of the APIs in the Qt Concurrent framework.

QFuture allows threads to be synchronized against one or more results which will be ready at a later point in time. The result can be of any type that has a default constructor and a copy constructor. If a result is not available at the time of calling the result(), resultAt(), or results() functions, QFuture will wait until the result becomes available. You can use the isResultReadyAt() function to determine if a result is ready or not. For QFuture objects that report more than one result, the resultCount() function returns the number of continuous results. This means that it is always safe to iterate through the results from 0 to resultCount().

QFuture provides a Java-style iterator (QFutureIterator) and an STL-style iterator (QFuture::const_iterator). Using these iterators is another way to access results in the future.

QFuture also offers ways to interact with a runnning computation. For instance, the computation can be canceled with the cancel() function. To pause the computation, use the setPaused() function or one of the pause(), resume(), or togglePaused() convenience functions. Be aware that not all asynchronous computations can be canceled or paused. For example, the future returned by QtConcurrent::run() cannot be canceled; but the future returned by QtConcurrent::mappedReduced() can.

Progress information is provided by the progressValue(), progressMinimum(), progressMaximum(), and progressText() functions. The waitForFinished() function causes the calling thread to block and wait for the computation to finish, ensuring that all results are available.

The state of the computation represented by a QFuture can be queried using the isCanceled(), isStarted(), isFinished(), isRunning(), or isPaused() functions.

QFuture is a lightweight reference counted class that can be passed by value.

QFuture<void> is specialized to not contain any of the result fetching functions. Any QFuture<T> can be assigned or copied into a QFuture<void> as well. This is useful if only status or progress information is needed - not the actual result data.

To interact with running tasks using signals and slots, use QFutureWatcher.

source

pub unsafe fn is_canceled(&self) -> bool

Returns true if the asynchronous computation has been canceled with the cancel() function; otherwise returns false.

Calls C++ function: bool QFuture<void>::isCanceled() const.

C++ documentation:

Returns true if the asynchronous computation has been canceled with the cancel() function; otherwise returns false.

Be aware that the computation may still be running even though this function returns true. See cancel() for more details.

source

pub unsafe fn is_finished(&self) -> bool

Returns true if the asynchronous computation represented by this future has finished; otherwise returns false.

Calls C++ function: bool QFuture<void>::isFinished() const.

C++ documentation:

Returns true if the asynchronous computation represented by this future has finished; otherwise returns false.

source

pub unsafe fn is_paused(&self) -> bool

Returns true if the asynchronous computation has been paused with the pause() function; otherwise returns false.

Calls C++ function: bool QFuture<void>::isPaused() const.

C++ documentation:

Returns true if the asynchronous computation has been paused with the pause() function; otherwise returns false.

Be aware that the computation may still be running even though this function returns true. See setPaused() for more details.

See also setPaused() and togglePaused().

source

pub unsafe fn is_running(&self) -> bool

Returns true if the asynchronous computation represented by this future is currently running; otherwise returns false.

Calls C++ function: bool QFuture<void>::isRunning() const.

C++ documentation:

Returns true if the asynchronous computation represented by this future is currently running; otherwise returns false.

source

pub unsafe fn is_started(&self) -> bool

Returns true if the asynchronous computation represented by this future has been started; otherwise returns false.

Calls C++ function: bool QFuture<void>::isStarted() const.

C++ documentation:

Returns true if the asynchronous computation represented by this future has been started; otherwise returns false.

source

pub unsafe fn new_0a() -> CppBox<QFutureOf>

Constructs an empty, canceled future.

Calls C++ function: [constructor] void QFuture<void>::QFuture().

C++ documentation:

Constructs an empty, canceled future.

source

pub unsafe fn new_1a( p: impl CastInto<Ptr<QFutureInterfaceOf>> ) -> CppBox<QFutureOf>

Constructs an empty, canceled future.

Calls C++ function: [constructor] void QFuture<void>::QFuture(QFutureInterface<void>* p).

Warning: no exact match found in C++ documentation. Below is the C++ documentation for QFuture::QFuture():

Constructs an empty, canceled future.

source

pub unsafe fn new_copy( other: impl CastInto<Ref<QFutureOf>> ) -> CppBox<QFutureOf>

The QFuture class represents the result of an asynchronous computation.

Calls C++ function: [constructor] void QFuture<void>::QFuture(const QFuture<void>& other).

C++ documentation:

The QFuture class represents the result of an asynchronous computation.

To start a computation, use one of the APIs in the Qt Concurrent framework.

QFuture allows threads to be synchronized against one or more results which will be ready at a later point in time. The result can be of any type that has a default constructor and a copy constructor. If a result is not available at the time of calling the result(), resultAt(), or results() functions, QFuture will wait until the result becomes available. You can use the isResultReadyAt() function to determine if a result is ready or not. For QFuture objects that report more than one result, the resultCount() function returns the number of continuous results. This means that it is always safe to iterate through the results from 0 to resultCount().

QFuture provides a Java-style iterator (QFutureIterator) and an STL-style iterator (QFuture::const_iterator). Using these iterators is another way to access results in the future.

QFuture also offers ways to interact with a runnning computation. For instance, the computation can be canceled with the cancel() function. To pause the computation, use the setPaused() function or one of the pause(), resume(), or togglePaused() convenience functions. Be aware that not all asynchronous computations can be canceled or paused. For example, the future returned by QtConcurrent::run() cannot be canceled; but the future returned by QtConcurrent::mappedReduced() can.

Progress information is provided by the progressValue(), progressMinimum(), progressMaximum(), and progressText() functions. The waitForFinished() function causes the calling thread to block and wait for the computation to finish, ensuring that all results are available.

The state of the computation represented by a QFuture can be queried using the isCanceled(), isStarted(), isFinished(), isRunning(), or isPaused() functions.

QFuture is a lightweight reference counted class that can be passed by value.

QFuture<void> is specialized to not contain any of the result fetching functions. Any QFuture<T> can be assigned or copied into a QFuture<void> as well. This is useful if only status or progress information is needed - not the actual result data.

To interact with running tasks using signals and slots, use QFutureWatcher.

source

pub unsafe fn pause(&self)

Pauses the asynchronous computation represented by this future. This is a convenience method that simply calls setPaused(true).

Calls C++ function: void QFuture<void>::pause().

C++ documentation:

Pauses the asynchronous computation represented by this future. This is a convenience method that simply calls setPaused(true).

See also resume().

source

pub unsafe fn progress_maximum(&self) -> c_int

Returns the maximum progressValue().

Calls C++ function: int QFuture<void>::progressMaximum() const.

C++ documentation:

Returns the maximum progressValue().

See also progressValue() and progressMinimum().

source

pub unsafe fn progress_minimum(&self) -> c_int

Returns the minimum progressValue().

Calls C++ function: int QFuture<void>::progressMinimum() const.

C++ documentation:

Returns the minimum progressValue().

See also progressValue() and progressMaximum().

source

pub unsafe fn progress_text(&self) -> CppBox<QString>

Returns the (optional) textual representation of the progress as reported by the asynchronous computation.

Calls C++ function: QString QFuture<void>::progressText() const.

C++ documentation:

Returns the (optional) textual representation of the progress as reported by the asynchronous computation.

Be aware that not all computations provide a textual representation of the progress, and as such, this function may return an empty string.

source

pub unsafe fn progress_value(&self) -> c_int

Returns the current progress value, which is between the progressMinimum() and progressMaximum().

Calls C++ function: int QFuture<void>::progressValue() const.

C++ documentation:

Returns the current progress value, which is between the progressMinimum() and progressMaximum().

See also progressMinimum() and progressMaximum().

source

pub unsafe fn result_count(&self) -> c_int

Returns the number of continuous results available in this future. The real number of results stored might be different from this value, due to gaps in the result set. It is always safe to iterate through the results from 0 to resultCount().

Calls C++ function: int QFuture<void>::resultCount() const.

C++ documentation:

Returns the number of continuous results available in this future. The real number of results stored might be different from this value, due to gaps in the result set. It is always safe to iterate through the results from 0 to resultCount().

See also result(), resultAt(), and results().

source

pub unsafe fn resume(&self)

Resumes the asynchronous computation represented by this future. This is a convenience method that simply calls setPaused(false).

Calls C++ function: void QFuture<void>::resume().

C++ documentation:

Resumes the asynchronous computation represented by this future. This is a convenience method that simply calls setPaused(false).

See also pause().

source

pub unsafe fn set_paused(&self, paused: bool)

If paused is true, this function pauses the asynchronous computation represented by the future. If the computation is already paused, this function does nothing. Any QFutureWatcher object that is watching this future will stop delivering progress and result ready signals while the future is paused. Signal delivery will continue once the future is resumed.

Calls C++ function: void QFuture<void>::setPaused(bool paused).

C++ documentation:

If paused is true, this function pauses the asynchronous computation represented by the future. If the computation is already paused, this function does nothing. Any QFutureWatcher object that is watching this future will stop delivering progress and result ready signals while the future is paused. Signal delivery will continue once the future is resumed.

If paused is false, this function resumes the asynchronous computation. If the computation was not previously paused, this function does nothing.

Be aware that not all computations can be paused. For example, the future returned by QtConcurrent::run() cannot be paused; but the future returned by QtConcurrent::mappedReduced() can.

See also isPaused(), pause(), resume(), and togglePaused().

source

pub unsafe fn toggle_paused(&self)

Toggles the paused state of the asynchronous computation. In other words, if the computation is currently paused, calling this function resumes it; if the computation is running, it is paused. This is a convenience method for calling setPaused(!isPaused()).

Calls C++ function: void QFuture<void>::togglePaused().

C++ documentation:

Toggles the paused state of the asynchronous computation. In other words, if the computation is currently paused, calling this function resumes it; if the computation is running, it is paused. This is a convenience method for calling setPaused(!isPaused()).

See also setPaused(), pause(), and resume().

source

pub unsafe fn wait_for_finished(&self)

Waits for the asynchronous computation to finish (including cancel()ed computations).

Calls C++ function: void QFuture<void>::waitForFinished().

C++ documentation:

Waits for the asynchronous computation to finish (including cancel()ed computations).

Trait Implementations§

source§

impl CppDeletable for QFutureOf

source§

unsafe fn delete(&self)

The QFuture class represents the result of an asynchronous computation.

Calls C++ function: [destructor] void QFuture<void>::~QFuture().

C++ documentation:

The QFuture class represents the result of an asynchronous computation.

To start a computation, use one of the APIs in the Qt Concurrent framework.

QFuture allows threads to be synchronized against one or more results which will be ready at a later point in time. The result can be of any type that has a default constructor and a copy constructor. If a result is not available at the time of calling the result(), resultAt(), or results() functions, QFuture will wait until the result becomes available. You can use the isResultReadyAt() function to determine if a result is ready or not. For QFuture objects that report more than one result, the resultCount() function returns the number of continuous results. This means that it is always safe to iterate through the results from 0 to resultCount().

QFuture provides a Java-style iterator (QFutureIterator) and an STL-style iterator (QFuture::const_iterator). Using these iterators is another way to access results in the future.

QFuture also offers ways to interact with a runnning computation. For instance, the computation can be canceled with the cancel() function. To pause the computation, use the setPaused() function or one of the pause(), resume(), or togglePaused() convenience functions. Be aware that not all asynchronous computations can be canceled or paused. For example, the future returned by QtConcurrent::run() cannot be canceled; but the future returned by QtConcurrent::mappedReduced() can.

Progress information is provided by the progressValue(), progressMinimum(), progressMaximum(), and progressText() functions. The waitForFinished() function causes the calling thread to block and wait for the computation to finish, ensuring that all results are available.

The state of the computation represented by a QFuture can be queried using the isCanceled(), isStarted(), isFinished(), isRunning(), or isPaused() functions.

QFuture is a lightweight reference counted class that can be passed by value.

QFuture<void> is specialized to not contain any of the result fetching functions. Any QFuture<T> can be assigned or copied into a QFuture<void> as well. This is useful if only status or progress information is needed - not the actual result data.

To interact with running tasks using signals and slots, use QFutureWatcher.

source§

impl PartialEq<Ref<QFutureOf>> for QFutureOf

source§

fn eq(&self, other: &Ref<QFutureOf>) -> bool

Returns true if other is a copy of this future; otherwise returns false.

Calls C++ function: bool QFuture<void>::operator==(const QFuture<void>& other) const.

C++ documentation:

Returns true if other is a copy of this future; otherwise returns false.

1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T, U> CastInto<U> for T
where U: CastFrom<T>,

source§

unsafe fn cast_into(self) -> U

Performs the conversion. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> StaticUpcast<T> for T

source§

unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>

Convert type of a const pointer. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.