pub struct EventLoop<TS: ThreadSafety = DefaultThreadSafety> { /* private fields */ }
Expand description
Provides a way to retrieve events from the system and from the windows that were registered to the events loop.
The EventLoop
is a “context” for the GUI system. More specifically, it represents a connection
to the underlying GUI system. The EventLoop
is the main object that you will use to drive
the program. Most async
functions in async-winit
rely on the EventLoop
to be currently
running.
The EventLoop
itself is !Send
and !Sync
due to underlying platform restrictions. However,
EventLoopWindowTarget
and [
Window] are both not only
Sendand
Sync`, but also cheaply
clonable. This means that you can create a window on one thread, and then send it to another
thread to be used.
Implementations§
Source§impl<TS: ThreadSafety> EventLoop<TS>
impl<TS: ThreadSafety> EventLoop<TS>
Sourcepub fn new() -> EventLoop<TS>
pub fn new() -> EventLoop<TS>
Alias for EventLoopBuilder::new().build()
.
Source§impl<TS: ThreadSafety + 'static> EventLoop<TS>
impl<TS: ThreadSafety + 'static> EventLoop<TS>
Sourcepub fn window_target(&self) -> &EventLoopWindowTarget<TS>
pub fn window_target(&self) -> &EventLoopWindowTarget<TS>
Manually get a reference to the event loop’s window target.
Sourcepub fn block_on(self, future: impl Future<Output = Infallible> + 'static) -> !
pub fn block_on(self, future: impl Future<Output = Infallible> + 'static) -> !
Block on a future forever.
Methods from Deref<Target = EventLoopWindowTarget<TS>>§
Sourcepub fn set_exit_with_code(&self, code: i32)
pub fn set_exit_with_code(&self, code: i32)
Request that we exit as soon as possible with the given exit code.
Sourcepub async fn exit_with_code(&self, code: i32) -> !
pub async fn exit_with_code(&self, code: i32) -> !
Exit the program with the given exit code.
Sourcepub async fn primary_monitor(&self) -> Option<MonitorHandle>
pub async fn primary_monitor(&self) -> Option<MonitorHandle>
Get the primary monitor.
Sourcepub async fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle>
pub async fn available_monitors(&self) -> impl Iterator<Item = MonitorHandle>
Get the available monitors.
Sourcepub async fn set_device_event_filter(&self, filter: DeviceEventFilter)
pub async fn set_device_event_filter(&self, filter: DeviceEventFilter)
Set the device event filter.
Trait Implementations§
Source§impl<TS: ThreadSafety> Debug for EventLoop<TS>
impl<TS: ThreadSafety> Debug for EventLoop<TS>
Source§impl<TS: ThreadSafety> Default for EventLoop<TS>
impl<TS: ThreadSafety> Default for EventLoop<TS>
Source§impl<TS: ThreadSafety> Deref for EventLoop<TS>
impl<TS: ThreadSafety> Deref for EventLoop<TS>
Source§impl<TS: ThreadSafety> DerefMut for EventLoop<TS>
impl<TS: ThreadSafety> DerefMut for EventLoop<TS>
Source§impl<TS: ThreadSafety> EventLoopExtRunReturn for EventLoop<TS>
impl<TS: ThreadSafety> EventLoopExtRunReturn for EventLoop<TS>
Source§fn block_on_return<F>(&mut self, fut: F) -> ReturnOrFinish<i32, F::Output>where
F: Future,
fn block_on_return<F>(&mut self, fut: F) -> ReturnOrFinish<i32, F::Output>where
F: Future,
winit
event loop. Read more