Smithay / calloop

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

Update for new polling breaking changes #141

Closed notgull closed 12 months ago

notgull commented 1 year ago

For now, this exists as a testing ground in order to test https://github.com/smol-rs/polling/pull/123 before we release it.

ids1024 commented 1 year ago

So, this makes Generic safe by having Drop and unwrap automatically unregister it from the event loop?

Interesting approach. Normally relying on Drop for safety properties is unsound, with mem::forget or reference cycles, but in this particular instance it's fine since that will also leak the fd. (In other words, I tried to break this and get it to poll an invalid fd using Generic, but I couldn't. So it looks sound.)

But this does mean that if a user of calloop implements EventSource to call Poll::register etc. directly, it should also implement Drop like this to ensure the same safety properties?

notgull commented 1 year ago

The only thing that matters is that the source isn't dropped while registered in a Poller. If anyone were to implement a similar abstraction to this, they would need to either follow these dropping rules or otherwise make sure that drop() isn't called before deregister().

notgull commented 1 year ago

I've updated this for the new polling release.

codecov[bot] commented 1 year ago

Codecov Report

Patch coverage: 82.69% and project coverage change: +0.17% :tada:

Comparison is base (d468cc9) 88.79% compared to head (4e805d6) 88.97%. Report is 2 commits behind head on master.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #141 +/- ## ========================================== + Coverage 88.79% 88.97% +0.17% ========================================== Files 14 14 Lines 1669 2140 +471 ========================================== + Hits 1482 1904 +422 - Misses 187 236 +49 ``` | [Flag](https://app.codecov.io/gh/Smithay/calloop/pull/141/flags?src=pr&el=flags&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay) | Coverage Δ | | |---|---|---| | [macos-latest](https://app.codecov.io/gh/Smithay/calloop/pull/141/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay) | `85.86% <71.08%> (-2.60%)` | :arrow_down: | | [ubuntu-latest](https://app.codecov.io/gh/Smithay/calloop/pull/141/flags?src=pr&el=flag&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay) | `86.35% <81.25%> (-2.02%)` | :arrow_down: | 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. | [Files Changed](https://app.codecov.io/gh/Smithay/calloop/pull/141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay) | Coverage Δ | | |---|---|---| | [src/sources/generic.rs](https://app.codecov.io/gh/Smithay/calloop/pull/141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3NvdXJjZXMvZ2VuZXJpYy5ycw==) | `75.63% <67.85%> (-3.25%)` | :arrow_down: | | [src/io.rs](https://app.codecov.io/gh/Smithay/calloop/pull/141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL2lvLnJz) | `78.09% <100.00%> (-4.46%)` | :arrow_down: | | [src/sources/signals.rs](https://app.codecov.io/gh/Smithay/calloop/pull/141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3NvdXJjZXMvc2lnbmFscy5ycw==) | `82.29% <100.00%> (+1.83%)` | :arrow_up: | | [src/sys.rs](https://app.codecov.io/gh/Smithay/calloop/pull/141?src=pr&el=tree&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay#diff-c3JjL3N5cy5ycw==) | `99.20% <100.00%> (+0.79%)` | :arrow_up: | ... and [2 files with indirect coverage changes](https://app.codecov.io/gh/Smithay/calloop/pull/141/indirect-changes?src=pr&el=tree-more&utm_medium=referral&utm_source=github&utm_content=comment&utm_campaign=pr+comments&utm_term=Smithay)

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

notgull commented 1 year ago

Ugh, looks like Github Actions is down.

elinorbgr commented 12 months ago

Alright, the CI is back. Also, even if git does not see any conflict, could you rebase on master for good measure?

elinorbgr commented 12 months ago

Okay, this looks good overall, but could you give more details about the NoIoDrop type that you introduced? Mostly what is its role and why is it needed? If possible as code/docs comments around this type, to make future maintainability easier.