Module event_loop

Module event_loop 

Source
Expand description

The EventLoop and associated structures.

There are three main differences between EventLoops here and in winit:

  • Instead of run or run_return, there are block_on and block_on_return, which take a future and run it to completion. Eent handling is done through the Handler structures instead.
  • Methods on EventLoop and EventLoopWindowTarget are async.
  • There is no EventLoopProxy type, since it is now obsolete with async blocks. Instead, consider using an async channel to communicate with the event loop.
use async_winit::event_loop::EventLoop;
use async_winit::ThreadUnsafe;

struct MyCustomType;

let (sender, receiver) = async_channel::unbounded();

EventLoop::<ThreadUnsafe>::new().block_on(async move {
    // Wait for a message from the channel.
    let message = receiver.recv().await.unwrap();
});

// In another thread, send a message to the event loop.
sender.send(MyCustomType).await.unwrap();

Structs§

EventLoop
Provides a way to retrieve events from the system and from the windows that were registered to the events loop.
EventLoopBuilder
Object that allows for building the EventLoop.
EventLoopClosed
The error that is returned when an EventLoopProxy attempts to wake up an EventLoop that no longer exists.
EventLoopWindowTarget
A reference to the EventLoop that allows the user access to the underlying display connections.
Wakeup
Used to indicate that we need to wake up the event loop.

Enums§

ControlFlow
Set by the user callback given to the EventLoop::run method.
DeviceEventFilter
Filter controlling the propagation of device events.