Struct cxx_qt::CxxQtThread
source · #[repr(C)]pub struct CxxQtThread<T>where
T: Threading,{ /* private fields */ }
Expand description
A threading helper which is created from a QObject that implements Threading.
This allows for queueing closures onto the Qt event loop from a background thread as CxxQtThread implements Send.
When the Rust thread needs to update a value in the QObject it can then queue a closure to the thread. This closure will be executed on the thread the QObject lives in while holding a lock on the Rust object. Updating the QObject is then thread-safe.
See the Threading example for more information.
Implementations§
source§impl<T> CxxQtThread<T>where
T: Threading,
impl<T> CxxQtThread<T>where
T: Threading,
sourcepub fn queue<F>(&self, f: F) -> Result<(), Exception>
pub fn queue<F>(&self, f: F) -> Result<(), Exception>
Queue the given closure onto the Qt event loop for this QObject
The first argument of the closure is a pinned mutable reference to the QObject. With this parameter, you can then update the QObject to reflect any state changes that have occured in the background thread.