Uh oh!
There was an error while loading. Please reload this page.
feat(lambda-rs): Add policy to control the event loops control-flow - #182
Conversation
✅ Coverage Report📊 View Full HTML Report (download artifact) Overall Coverage
Changed Files in This PR
PR Files Coverage: 61.62% (1259/2043 lines) Generated by cargo-llvm-cov · Latest main coverage Last updated: 2026-02-10 21:37:11 UTC · Commit: |
There was a problem hiding this comment.
Pull request overview
Adds an opt-in winit event loop control-flow policy to Lambda runtimes so applications can avoid continuous polling and reduce CPU/power usage when idle, while preserving Poll as the default for backward compatibility.
Changes:
- Introduces
EventLoopPolicy(Poll,Wait,WaitUntil { target_fps }) andLoop::run_forever_with_policy(...)in the platform winit wrapper. - Wires policy through
ApplicationRuntimeBuilder::with_event_loop_policy(...)intoApplicationRuntimeexecution. - Updates public exports and docs/examples to demonstrate
EventLoopPolicy::Wait, and fixes a clippynever_looplint.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| crates/lambda-rs/src/runtimes/mod.rs | Re-exports EventLoopPolicy for easier consumption from lambda::runtimes. |
| crates/lambda-rs/src/runtimes/application.rs | Adds policy to the runtime builder and uses it when running the event loop. |
| crates/lambda-rs/src/render/mod.rs | Removes an unnecessary return to satisfy clippy linting. |
| crates/lambda-rs/examples/minimal.rs | Demonstrates configuring the runtime with EventLoopPolicy::Wait. |
| crates/lambda-rs/README.md | Updates getting-started snippet to include and recommend EventLoopPolicy::Wait for event-driven apps. |
| crates/lambda-rs-platform/src/winit/mod.rs | Implements EventLoopPolicy and run_forever_with_policy mapping to winit ControlFlow. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
…adline is always greater than now.
Summary
Add an opt-in, configurable winit event loop control-flow policy so apps that don’t need continuous rendering (tools/editors) can avoid
ControlFlow::Polland reduce CPU/power usage when idle.Related Issues
Changes
EventLoopPolicy(Poll,Wait,WaitUntil { target_fps }) to the winit wrapper and implementLoop::run_forever_with_policy(...).ApplicationRuntimeBuilder::with_event_loop_policy(...)(defaults toPollfor backwards compatibility) and wire it intoApplicationRuntimeexecution.EventLoopPolicyfromlambda::runtimesfor easy consumption.EventLoopPolicy::Waitfor event-driven apps.never_looplint failure by removing an unnecessaryreturninside an iterator adapter closure.Type of Change
Affected Crates
lambda-rslambda-rs-platformlambda-rs-argslambda-rs-loggingChecklist
cargo +nightly fmt --all)cargo clippy --workspace --all-targets -- -D warnings)cargo test --workspace)Testing
Commands run:
cargo +nightly fmt --all rustup run nightly cargo clippy --workspace --all-targets -- -D warnings cargo test --workspaceManual verification steps (if applicable):
EventLoopPolicy::Wait.Screenshots/Recordings
N/A
Platform Testing
Additional Notes
Pollto avoid behavior changes for existing applications unless they opt in.WaitUntilis best-effort wakeup scheduling (control-flow only), not frame pacing/vsync.