Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: use async trait #323

Merged
merged 7 commits into from
Jul 28, 2021
Merged

feat: use async trait #323

merged 7 commits into from
Jul 28, 2021

Conversation

driftluo
Copy link
Collaborator

@driftluo driftluo commented Apr 22, 2021

ref #305

This PR achieves a complete migration to the async trait, users can write code in async env

tentacle/src/traits.rs is the core of the modification
tentacle/src/channel/bound.rs Channels adds two async methods that do not use mut to facilitate the uniformity of the user interface and avoid unnecessary mut marks
tentacle/src/protocol_handle_stream.rs and tentacle/src/service.rs as the place to inherit the implementation of the user’s async trait, part of the logic is inevitably rewritten

Other changes are due to the changes caused by the above changes


This change is Reviewable

@driftluo driftluo force-pushed the use-async-trait branch 3 times, most recently from 56c49b8 to ef647d0 Compare May 7, 2021 02:15
@driftluo driftluo marked this pull request as ready for review May 7, 2021 06:31
@driftluo driftluo requested a review from TheWaWaR as a code owner May 7, 2021 06:31
@driftluo driftluo requested review from a team and doitian May 7, 2021 06:31
tentacle/src/service.rs Outdated Show resolved Hide resolved
@@ -536,25 +420,33 @@ where
// Send data to the specified protocol for the specified session.
TargetSession::Single(id) => {
if let Some(control) = self.sessions.get_mut(&id) {
control.push_message(proto_id, priority, data);
control.try_send(cx);
control.inner.incr_pending_data_size(data.len());
Copy link
Collaborator

@TheWaWaR TheWaWaR May 17, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Better incr_pending_data_size() inside control.send() (by destruct SessionEvent::ProtocolMessage) in case we don't forget it before send ProtocolMessage.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

incr_pending_data_size only exists in this function, there is no need for the operation of this function to cause all other commands to also carry the destruct operation

Copy link
Member

@doitian doitian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reviewed 37 of 37 files at r1.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @driftluo)

@driftluo driftluo merged commit 6db2793 into master Jul 28, 2021
@driftluo driftluo deleted the use-async-trait branch July 28, 2021 06:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants