pub struct MessageLoop { /* private fields */ }
Expand description
Abstract representation of a message loop.
Not directly constructible, use MessageLoop::run
to create a message
loop. The message loop struct is used to control the message loop behavior
by passing it as an argument to the filter closure of MessageLoop::run
.
Implementations§
Source§impl MessageLoop
impl MessageLoop
Sourcepub fn run(filter: impl Fn(&MessageLoop, &MSG) -> FilterResult)
pub fn run(filter: impl Fn(&MessageLoop, &MSG) -> FilterResult)
Runs the message loop with a filter closure to inspect and drop messages before they are dispatched to their respective window procedure.
Use the FilterResult
return value to control how the message is
handled. The first argument to the filter closure is the MessageLoop
struct itself, which can be used to quit out of the message loop.
Like block_on
this function runs any tasks [spawn
]ed from the same
thread. Any spawned tasks will be suspended when the run_message_loop
returns. Be careful not to drop messages not belonging to a window you
control or you might risk suspending a task indefinitely when dropping
its wake message.
run_message_loop
installs a WH_MSGFILTER
hook to allow inspections
of messages while modal windows are open.
§Panics and Reentrancy
Panics when called from within another run_message_loop
filter closure.
A call to block_on()
from within the filter closure creates a nested
message loop which causes the filter closure to be reentered when a modal
window is open.
Sourcepub fn quit_when_idle(&self)
pub fn quit_when_idle(&self)
Quits the message loop when there are no more messages to process.