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

Update documentation to mention possibility of deadlock #3389

Merged
merged 4 commits into from Jan 28, 2021

Conversation

Hodkinson
Copy link
Contributor

@Hodkinson Hodkinson commented Jan 7, 2021

Motivation

Add detail about why deadlocks might be encountered when a read lock attempt is made following a successful read lock followed by a write lock attempt by the same task.

Solution

Update documentation in #2849

@Darksonn Darksonn added A-tokio Area: The main tokio crate M-sync Module: tokio/sync T-docs Topic: documentation labels Jan 7, 2021
Copy link
Contributor

@Darksonn Darksonn left a comment

Choose a reason for hiding this comment

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

Thank you for the PR!

tokio/src/sync/rwlock.rs Outdated Show resolved Hide resolved
/// The calling task will yield until there are no writers which hold the
/// lock. There may be other readers inside the lock when the task resumes.
///
/// Note that under the priority policy of [`RwLock`], read locks are not
Copy link
Member

Choose a reason for hiding this comment

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

It would be helpful to include a code example demonstrating the error.

Copy link
Member

@carllerche carllerche left a comment

Choose a reason for hiding this comment

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

LGTM, I think the doc would be clearer w/ a code snippet demonstrating how to get into the deadlock case.

@Darksonn Darksonn merged commit 225e8ea into tokio-rs:master Jan 28, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-sync Module: tokio/sync T-docs Topic: documentation
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants