Closed notgull closed 12 months 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?
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()
.
I've updated this for the new polling
release.
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.
:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.
Ugh, looks like Github Actions is down.
Alright, the CI is back. Also, even if git does not see any conflict, could you rebase on master for good measure?
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.
For now, this exists as a testing ground in order to test https://github.com/smol-rs/polling/pull/123 before we release it.