[][src]Function qmetaobject::queued_callback

pub fn queued_callback<T: Send, F: FnMut(T) + 'static>(
    func: F
) -> impl Fn(T) + Send + Sync + Clone

Create a callback to invoke a queued callback in the current thread.

Returns a callback that can be called in any thread. Calling the callback will then call the given closure in the current Qt thread.

If the current thread does no longer have an event loop when the callback is sent, the callback will not be recieved.

// in this example, we do not pass '()' as an argument.
let callback = queued_callback(|()| println!("hello from main thread"));
std::thread::spawn(move || {callback(());}).join();