Struct qt_core::QRunnable

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

The QRunnable class is the base class for all runnable objects.

C++ class: QRunnable.

C++ documentation:

The QRunnable class is the base class for all runnable objects.

The QRunnable class is an interface for representing a task or piece of code that needs to be executed, represented by your reimplementation of the run() function.

You can use QThreadPool to execute your code in a separate thread. QThreadPool deletes the QRunnable automatically if autoDelete() returns true (the default). Use setAutoDelete() to change the auto-deletion flag.

QThreadPool supports executing the same QRunnable more than once by calling QThreadPool::tryStart(this) from within the run() function. If autoDelete is enabled the QRunnable will be deleted when the last thread exits the run function. Calling QThreadPool::start() multiple times with the same QRunnable when autoDelete is enabled creates a race condition and is not recommended.

Implementations§

source§

impl QRunnable

source

pub unsafe fn auto_delete(&self) -> bool

Returns true is auto-deletion is enabled; false otherwise.

Calls C++ function: bool QRunnable::autoDelete() const.

C++ documentation:

Returns true is auto-deletion is enabled; false otherwise.

If auto-deletion is enabled, QThreadPool will automatically delete this runnable after calling run(); otherwise, ownership remains with the application programmer.

See also setAutoDelete() and QThreadPool.

source

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

The QRunnable class is the base class for all runnable objects.

Calls C++ function: QRunnable& QRunnable::operator=(const QRunnable& other).

C++ documentation:

The QRunnable class is the base class for all runnable objects.

The QRunnable class is an interface for representing a task or piece of code that needs to be executed, represented by your reimplementation of the run() function.

You can use QThreadPool to execute your code in a separate thread. QThreadPool deletes the QRunnable automatically if autoDelete() returns true (the default). Use setAutoDelete() to change the auto-deletion flag.

QThreadPool supports executing the same QRunnable more than once by calling QThreadPool::tryStart(this) from within the run() function. If autoDelete is enabled the QRunnable will be deleted when the last thread exits the run function. Calling QThreadPool::start() multiple times with the same QRunnable when autoDelete is enabled creates a race condition and is not recommended.

source

pub unsafe fn run(&self)

Implement this pure virtual function in your subclass.

Calls C++ function: pure virtual void QRunnable::run().

C++ documentation:

Implement this pure virtual function in your subclass.

source

pub unsafe fn set_auto_delete(&self, auto_delete: bool)

Enables auto-deletion if autoDelete is true; otherwise auto-deletion is disabled.

Calls C++ function: void QRunnable::setAutoDelete(bool _autoDelete).

C++ documentation:

Enables auto-deletion if autoDelete is true; otherwise auto-deletion is disabled.

If auto-deletion is enabled, QThreadPool will automatically delete this runnable after calling run(); otherwise, ownership remains with the application programmer.

Note that this flag must be set before calling QThreadPool::start(). Calling this function after QThreadPool::start() results in undefined behavior.

See also autoDelete() and QThreadPool.

Trait Implementations§

source§

impl CppDeletable for QRunnable

source§

unsafe fn delete(&self)

QRunnable virtual destructor.

Calls C++ function: virtual [destructor] void QRunnable::~QRunnable().

C++ documentation:

QRunnable virtual destructor.

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.