Skip to content

Commit 7cdcf69

Browse files
committed
[update] the event loop builder.
1 parent e64d4c9 commit 7cdcf69

2 files changed

Lines changed: 9 additions & 8 deletions

File tree

  • crates/lambda-platform/src/winit
  • lambda/src/runtimes

crates/lambda-platform/src/winit/mod.rs

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,11 @@ pub mod winit_exports {
3939
pub struct LoopBuilder;
4040

4141
impl LoopBuilder {
42-
pub fn build<Events: 'static + std::fmt::Debug>() -> Loop<Events> {
42+
pub fn new() -> Self {
43+
return Self;
44+
}
45+
46+
pub fn build<Events: 'static + std::fmt::Debug>(self) -> Loop<Events> {
4347
let event_loop = EventLoop::<Events>::with_user_event();
4448
return Loop { event_loop };
4549
}
@@ -182,15 +186,11 @@ fn construct_window_size(
182186
};
183187
}
184188

189+
/// Event loop publisher wrapper for pushing events into a winit event loop.
185190
pub struct LoopPublisher<E: 'static> {
186191
winit_proxy: EventLoopProxy<E>,
187192
}
188193

189-
#[derive(Clone, Debug)]
190-
pub struct EventLoopPublisher<E: 'static + std::fmt::Debug> {
191-
winit_proxy: EventLoopProxy<E>,
192-
}
193-
194194
impl<E: 'static + std::fmt::Debug> LoopPublisher<E> {
195195
/// Instantiate a new EventLoopPublisher from an event loop proxy.
196196
#[inline]
@@ -238,7 +238,7 @@ impl<E: 'static + std::fmt::Debug> Loop<E> {
238238
}
239239
}
240240

241-
/// Uses the winit event loop to run forever.
241+
/// Uses the winit event loop to run forever
242242
pub fn run_forever<Callback>(self, callback: Callback)
243243
where
244244
Callback: 'static

lambda/src/runtimes/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ use lambda_platform::winit::{
88
WindowEvent as WinitWindowEvent,
99
},
1010
Loop,
11+
LoopBuilder,
1112
};
1213

1314
use crate::core::{
@@ -82,7 +83,7 @@ impl GenericRuntimeBuilder {
8283
/// Kernel to receive events & render access.
8384
pub fn build(self) -> GenericRuntime {
8485
let name = self.app_name;
85-
let mut event_loop = create_event_loop::<Events>();
86+
let mut event_loop = LoopBuilder::new().build();
8687
let (width, height) = self.window_size;
8788

8889
let window = WindowBuilder::new()

0 commit comments

Comments
 (0)