Wrap the temporarily stored user callback in a type to enforce
invariants This also removes the need for "box"ing the callback in favour of storing a raw `*mut` pointer. We can do this by ensuring that we never store the pointer for longer than the lifetime of the user callback, which is the duration of a call to `poll_events` or `run_forever`. Also removes old commented out event code from the window module.
This commit is contained in:
parent
c03311fa2d
commit
3ce7904e01
3 changed files with 109 additions and 315 deletions
11
tests/events_loop.rs
Normal file
11
tests/events_loop.rs
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
extern crate winit;
|
||||
|
||||
// A part of the API requirement for `EventsLoop` is that it is `Send` + `Sync`.
|
||||
//
|
||||
// This short test will only compile if the `EventsLoop` is `Send` + `Sync`.
|
||||
#[test]
|
||||
fn send_sync() {
|
||||
fn check_send_sync<T: Send + Sync>(_: T) {}
|
||||
let events_loop = winit::EventsLoop::new();
|
||||
check_send_sync(events_loop);
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue