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

Adds example to async_std::task::spawn #830

Open
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

tronta
Copy link

@tronta tronta commented Jul 8, 2020

As I struggled using the function spawn properly (I didn't get that it can be executed without await :-( ), I'd like to add an other example.

Peter Sonntag and others added 3 commits July 8, 2020 21:07
shortens count down
disables check because of errors with #[async_std::main]
Copy link
Contributor

@yoshuawuyts yoshuawuyts left a comment

Choose a reason for hiding this comment

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

Hi, thanks for opening this PR! -- In the top-level documentation we explain in more detail how the task model works. However it seems we don't link to it from this function which we probably should.

I'm not sure if this example is the best way to convey how task::spawn works. Instead it may be more effective to adapt the std::thread::spawn documentation to cover async_std::task::spawn:

The join handle will implicitly detach the child task upon being dropped. In this case, the child task may outlive the parent [...]

@tronta
Copy link
Author

tronta commented Jul 10, 2020

Yes, the toplevel description. Would have helped me.
In my opinion, more examples are better than less 😀
What do you think, should be modified? Or do you suggest, this is enough...?
Probably one needs to weigh up the maintenance effort.

@yoshuawuyts
Copy link
Contributor

@tronta hah, yay glad that would've helped -- I would prefer we adapt the docs from std::thread for this instead -- putting this behavior into words is probably the right approach here.

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