pub struct EventLoop { /* private fields */ }
Expand description

A proxy event loop.

Similar API to winit::event_loop::EventLoop, except:

  • You can create multiples of these and even run them at the same time, on separate threads
  • You can create these on separate threads
  • You can stop these loops without exiting your entire application

The “actual” single event loop must be created via [winit_modular::run]. This forwards all of its messages to the event loop using channels and returns the responses.

Implementations

Creates a new proxy event loop. However it must first be registered, so this is async.

Runs an arbitrary closure on the main / UI thread.

Note that the closure must be 'static, which means it can’t reference local variables.

To get around this, you can convert them to raw pointers, wrap them in an unsafe Send struct, and unsafe dereference them inside the closure. This should actually be 100% safe as long as you await and do not drop the Future, as those references will remain alive and won’t be dereferenced outside of the closure until the future ends.

Alternatively, to get around this without unsafe, you can move the local variables into the closure and then return them along with your “real” result.

In the future, we may provide more methods to work around this limitation.

Creates a new Window, using the function to add arguments

Receives new and buffered events and responses from the main loop, blocking waiting for new responses, until the event handler explicitly exits.

The third argument to event_handler is whether the event is buffered (i.e. sent before this was called) or new.

Receives new and buffered events and responses from the main loop, blocking waiting for new responses, until the event handler explicitly exits.

The third argument to event_handler is whether the event is buffered (i.e. sent before this was called) or new.

Receives all buffered events and responses from the main loop, not blocking for new events.

You can set ControlFlow to exit locally or exit the app, but ControlFlow::Wait and ControlFlow::WaitUntil won’t do anything.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.