feat(lambda-rs): Add policy to control the event loops control-flow#182
Merged
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.
…adline is always greater than now.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.