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

tokio command for non blocking sys call #199

Merged
merged 3 commits into from
Aug 31, 2020
Merged

Conversation

o2sh
Copy link
Owner

@o2sh o2sh commented Aug 29, 2020

Following the discussion in #186
Turns out tokio provides a non blocking Command function which returns a Future.

The code is now effectively asynchronous :

get_language_stats --> 2.768313294s
get_configuration --> 21.916µs
get_current_commit_info --> 774.652µs
get_project_license --> 263.539183ms
get_version --> 292.895558ms
get_pending_pending --> 293.050209ms
get_last_change --> 294.630701ms
get_git_info --> 298.447978ms
get_packed_size --> 388.507071ms
get_commits --> 10.346720716s
get_creation_time --> 15.720670077s
get_authors --> 15.944136695s

The code is unfortunately less clean as I had to replace the async block with a separate function get_info_lines in order to mark it with the #[tokio::main], @spenserblack maybe it can be improved ?

@o2sh o2sh requested a review from spenserblack August 29, 2020 23:42
Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

Looks great! I didn't even know tokio provided an async version of Command 🙃

The code is unfortunately less clean as I had to replace the async block with a separate function

Could Info::new itself be given the #[tokio::main] attribute instead of a new function?

@o2sh
Copy link
Owner Author

o2sh commented Aug 30, 2020

Could Info::new itself be given the #[tokio::main] attribute instead of a new function?

Done.
By doing so, I add to make the Info::new function async which then allowed me to get rid of the nested async block.

@o2sh o2sh requested a review from spenserblack August 30, 2020 22:05
Copy link
Collaborator

@spenserblack spenserblack left a comment

Choose a reason for hiding this comment

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

🎉

@spenserblack spenserblack merged commit ebe5b5b into master Aug 31, 2020
@o2sh o2sh deleted the feature/tokio-command branch November 4, 2020 13:16
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.

2 participants