mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-26 19:03:27 +00:00
Finally, this commit implements an iface event observer trait for the `ConnectingStream`, `ListenStream`, and `ConnectedStream` states in `StreamSocket`, as well as the `BoundDatagram` state in `DatagramSocket`. It also moves the `Pollee` from `AnyBoundSocket` to these observer implementors. What I have tried to do is minimize the semantic changes. Ideally, this commit should be a pure refactor commit, meaning that even if the sematics of the previous code is wrong, the sematics after this commit should be wrong in the same way. Fixing the wrong sematics should be done in a separate commit afterwards. However, keeping exactly the same sematics for `ListenStream` is hard. We used to maintain a `Pollee` for each `BacklogSocket`, but now we can just maintain one `Pollee` for the whole `ListenStream`. However, implementing the correct semantics looks much easier, so we just do it. For `ConnectingStream`, it used to share the same `Pollee` logic with `ConnectedStream` (because the `Pollee` was maintained by `AnyBoundSocket`, which is used by both). Now we write the `Pollee` logic separately for `ConnectingStream`, so we can just write a correct one or try to reuse the logic in `ConnectingStream`. This commit does the former. There should be no semantic changes for `ConnectedStream` in `StreamSocket` and `BoundDatagram` in `DatagramSocket`.