Smithay / calloop

A callback-based Event Loop
MIT License
176 stars 35 forks source link

Add a "block_on" function for executing futures #120

Closed notgull closed 1 year ago

notgull commented 1 year ago

This PR adds a "block on" function to the EventLoop that serves a similar purpose as the block_on() function from async_io, where the event loop is polled during periods where the future would normally be blocked. I gated it behind a block_on feature, please let me know if it would be better to not gate it.

elinorbgr commented 1 year ago

Thanks for your PR. It looks like a pretty good addition! Could you add a changelog entry for this addition please?

codecov[bot] commented 1 year ago

Codecov Report

Base: 88.71% // Head: 89.79% // Increases project coverage by +1.08% :tada:

Coverage data is based on head (defaf87) compared to base (80819fa). Patch coverage: 98.64% of modified lines in pull request are covered.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #120 +/- ## ========================================== + Coverage 88.71% 89.79% +1.08% ========================================== Files 14 17 +3 Lines 1444 1784 +340 ========================================== + Hits 1281 1602 +321 - Misses 163 182 +19 ``` | Flag | Coverage Δ | | |---|---|---| | macos-latest | `89.29% <98.64%> (+0.58%)` | :arrow_up: | | ubuntu-latest | `88.20% <98.64%> (?)` | | Flags with carried forward coverage won't be shown. [Click here](https://docs.codecov.io/docs/carryforward-flags?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#carryforward-flags-in-the-pull-request-comment) to find out more. | [Impacted Files](https://codecov.io/gh/Smithay/calloop/pull/120?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay) | Coverage Δ | | |---|---|---| | [src/loop\_logic.rs](https://codecov.io/gh/Smithay/calloop/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL2xvb3BfbG9naWMucnM=) | `92.18% <98.64%> (+2.14%)` | :arrow_up: | | [src/sources/ping/eventfd.rs](https://codecov.io/gh/Smithay/calloop/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3NvdXJjZXMvcGluZy9ldmVudGZkLnJz) | `92.20% <0.00%> (ø)` | | | [src/sources/signals.rs](https://codecov.io/gh/Smithay/calloop/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3NvdXJjZXMvc2lnbmFscy5ycw==) | `80.23% <0.00%> (ø)` | | | [src/sys/epoll.rs](https://codecov.io/gh/Smithay/calloop/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3N5cy9lcG9sbC5ycw==) | `98.14% <0.00%> (ø)` | | | [src/sys/mod.rs](https://codecov.io/gh/Smithay/calloop/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3N5cy9tb2QucnM=) | `93.27% <0.00%> (+2.52%)` | :arrow_up: | | [src/error.rs](https://codecov.io/gh/Smithay/calloop/pull/120/diff?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL2Vycm9yLnJz) | `33.33% <0.00%> (+33.33%)` | :arrow_up: | Help us with your feedback. Take ten seconds to tell us [how you rate us](https://about.codecov.io/nps?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay). Have a feature suggestion? [Share it here.](https://app.codecov.io/gh/feedback/?utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay)

:umbrella: View full report at Codecov.
:loudspeaker: Do you have feedback about the report comment? Let us know in this issue.

notgull commented 1 year ago

@vberger Is there anything blocking this from being merged?

elinorbgr commented 1 year ago

Apart for my own availability, no. Thanks!