Skip to content

Example about explicit mutex dropping - #73104

Merged
bors merged 7 commits into
rust-lang:masterfrom
poliorcetics:explicit-mutex-drop-example
Jun 15, 2020
Merged

Example about explicit mutex dropping#73104
bors merged 7 commits into
rust-lang:masterfrom
poliorcetics:explicit-mutex-drop-example

Conversation

@poliorcetics

Copy link
Copy Markdown
Contributor

Fixes#67457.

Following the remarks made in #73074, I added an example on the main Mutex type, with a situation where there is mutable data and a computation result.

In my testing it is effectively needed to explicitly drop the lock, else it deadlocks.

r? @dtolnay because you were the one to review the previous PR.

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 7, 2020
Comment threadsrc/libstd/sync/mutex.rs Outdated
Comment threadsrc/libstd/sync/mutex.rs Outdated
Co-authored-by: LeSeulArtichaut <leseulartichaut@gmail.com>

@nagisanagisa left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

NB: Review comments I made are entirely a suggestion, they in no way mean I reject (were comments not resolved) or approve (once/if the comments are resolved) the PR.

Comment threadsrc/libstd/sync/mutex.rs
Comment threadsrc/libstd/sync/mutex.rs
@poliorcetics

Copy link
Copy Markdown
ContributorAuthor

@nagisa I removed a lot of comments. Aside from the ones about the dummy work, there is only the big comment about deadlocking in main, which explains pretty much everything (I hope).

Do not hesitate to tell me if you see something else I can improve !

@poliorcetics

Copy link
Copy Markdown
ContributorAuthor

@rustbot modify labels: C-enhancement, T-doc, T-libs

@rustbotrustbot added C-enhancement Category: An issue proposing an enhancement or a PR with one. A-docs Area: Documentation for any part of the project, including the compiler, standard library, and tools T-libs-api [DEPRECATED; DO NOT USE] labels Jun 11, 2020
Comment threadsrc/libstd/sync/mutex.rs Outdated
Comment threadsrc/libstd/sync/mutex.rs Outdated
Comment threadsrc/libstd/sync/mutex.rs Outdated
Comment threadsrc/libstd/sync/mutex.rs Outdated
Comment threadsrc/libstd/sync/mutex.rs Outdated
Comment threadsrc/libstd/sync/mutex.rs Outdated
poliorceticsand others added 2 commits June 13, 2020 18:41
Co-authored-by: David Tolnay <dtolnay@gmail.com>
Based on the review made by dtolnay.

@dtolnaydtolnay left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks!

@dtolnay

Copy link
Copy Markdown
Member

@bors r+

@bors

bors commented Jun 13, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit c010e71 has been approved by dtolnay

@borsbors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jun 13, 2020
@poliorcetics

Copy link
Copy Markdown
ContributorAuthor

I'm sorry you had to do a formatting commit, running rustfmt did nothing to the file locally for me.

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jun 14, 2020
…ample, r=dtolnay
Example about explicit mutex dropping
Fixesrust-lang#67457.
Following the remarks made in rust-lang#73074, I added an example on the main `Mutex` type, with a situation where there is mutable data and a computation result.
In my testing it is effectively needed to explicitly drop the lock, else it deadlocks.
r? @dtolnay because you were the one to review the previous PR.
@RalfJung

Copy link
Copy Markdown
Member

@bors rollup

RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 15, 2020
…ample, r=dtolnay
Example about explicit mutex dropping
Fixesrust-lang#67457.
Following the remarks made in rust-lang#73074, I added an example on the main `Mutex` type, with a situation where there is mutable data and a computation result.
In my testing it is effectively needed to explicitly drop the lock, else it deadlocks.
r? @dtolnay because you were the one to review the previous PR.
This was referenced Jun 15, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Jun 15, 2020
Rollup of 10 pull requests
Successful merges:
- rust-lang#72707 (Use min_specialization in the remaining rustc crates)
- rust-lang#72740 (On recursive ADT, provide indirection structured suggestion)
- rust-lang#72879 (Miri: avoid tracking current location three times)
- rust-lang#72938 (Stabilize Option::zip)
- rust-lang#73086 (Rename "cyclone" to "apple-a7" per changes in upstream LLVM)
- rust-lang#73104 (Example about explicit mutex dropping)
- rust-lang#73139 (Add methods to go from a nul-terminated Vec<u8> to a CString)
- rust-lang#73296 (Remove vestigial CI job msvc-aux.)
- rust-lang#73304 (Revert heterogeneous SocketAddr PartialEq impls)
- rust-lang#73331 (extend network support for HermitCore)
Failed merges:
r? @ghost
@bors
bors merged commit 7c8b941 into rust-lang:masterJun 15, 2020
@poliorcetics
poliorcetics deleted the explicit-mutex-drop-example branch June 16, 2020 21:18
@cuvipercuviper added this to the 1.46 milestone May 2, 2024
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-docsArea: Documentation for any part of the project, including the compiler, standard library, and toolsC-enhancementCategory: An issue proposing an enhancement or a PR with one.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-libs-api[DEPRECATED; DO NOT USE]

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Example CondVar code should explicitly drop the MutexGuard after it's done with it

9 participants

@poliorcetics@dtolnay@bors@RalfJung@nagisa@LeSeulArtichaut@cuviper@rust-highfive@rustbot