-
Notifications
You must be signed in to change notification settings - Fork 13.3k
Tracking Issue for {Arc, Rc}::into_inner
#106894
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
…r=Mark-Simulacrum Add `Arc::into_inner` for safely discarding `Arc`s without calling the destructor on the inner type. ACP: rust-lang/libs-team#162 Reviving rust-lang#79665. I want to get this merged this time; this does not contain changes (apart from very minor changes in comments/docs). See rust-lang#79665 for further description of the PR. The only “unresolved” points that led to that PR being closed, AFAICT, were * The desire to also implement a `Rc::into_inner` function * however, this can very well also happen as a subsequent PR * Possible need for further discussion on the naming “`into_inner`” (?) * `into_inner` seems fine to me; also, this PR introduces unstable API, and names can be changed later, too * ~~I don't know if a tracking issue for the feature flag is supposed to be opened before or after this PR gets merged (if *before*, then I can add the issue number to the `#[unstable…]` attribute)~~ There is a [tracking issue](rust-lang#106894) now. I say “unresolved” in quotation marks because from my point of view, if reviewers agree, the PR can be merged immediately and as-is :-)
Hey, I've stumbled on this. I wonder how soon this can be stabilized? My usecase is complex. but in a nut shell, I want this to conditionally and cleanly restart bunch of interconnected threads of mixed roles, all sharing if sharing helps, i can write the usecase in detail... Of course, I can resort to sync::Weak or tls. but it incurs overhead and/or further complexities. or |
Submitted the |
I think @rust-lang/libs-api, shall we stabilize these? @rfcbot merge |
Team member @joshtriplett has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
…, r=joshtriplett Stabilize `arc_into_inner` and `rc_into_inner`. Stabilize the `arc_into_inner` and `rc_into_inner` library features and thus close rust-lang#106894. The changes in this PR also resolve the FIXMEs for adjusting the documentation upon stabilization, and I’ve additionally included some very minor documentation improvements. `@rustbot` label +T-libs-api -T-libs
…, r=joshtriplett Stabilize `arc_into_inner` and `rc_into_inner`. Stabilize the `arc_into_inner` and `rc_into_inner` library features and thus close rust-lang#106894. The changes in this PR also resolve the FIXMEs for adjusting the documentation upon stabilization, and I’ve additionally included some very minor documentation improvements. ``@rustbot`` label +T-libs-api -T-libs
…mulacrum Add `Arc::into_inner` for safely discarding `Arc`s without calling the destructor on the inner type. ACP: rust-lang/libs-team#162 Reviving #79665. I want to get this merged this time; this does not contain changes (apart from very minor changes in comments/docs). See #79665 for further description of the PR. The only “unresolved” points that led to that PR being closed, AFAICT, were * The desire to also implement a `Rc::into_inner` function * however, this can very well also happen as a subsequent PR * Possible need for further discussion on the naming “`into_inner`” (?) * `into_inner` seems fine to me; also, this PR introduces unstable API, and names can be changed later, too * ~~I don't know if a tracking issue for the feature flag is supposed to be opened before or after this PR gets merged (if *before*, then I can add the issue number to the `#[unstable…]` attribute)~~ There is a [tracking issue](rust-lang/rust#106894) now. I say “unresolved” in quotation marks because from my point of view, if reviewers agree, the PR can be merged immediately and as-is :-)
Probably I'm too late here, but I think the fn unbox_from_arc(arc: Arc<T>) -> T {
if Arc::strong_count(&arc) == 1 {
// RACE CONDITION: another thread could upgrade a corresponding Weak<T> at this moment
return Arc::into_inner(arc)
// We have no chance to recover from the failure, since `arc` was consumed by`Arc::into_inner`
// the only thing we could do is to panic
.unwrap();
}
} Since In theory, the above issue is not applicable for |
@thynson Feel free to open an issue if you have concrete ideas how the documentation of Maybe also a doc alias “ |
Umm, it's my bad that /// ...
///
/// The similar expression `Arc::try_unwrap(this).ok()` does not
/// offer such a guarantee. See the last example below
/// and the documentation of [`Arc::try_unwrap`].
///
/// ...
Actually they're designed for different scenarios. Probably better to document it like: /// ...
///
/// `Arc::try_unwrap` offers similar functionality but it's designed
/// for difference scenarios, while this function is suitable for dropping
/// a clone of an `Arc`, obtaining the wrapped `T` when the last clone of an
/// `Arc` was dropped.
///
/// ...
|
Hmm, no On the other hand, I wasn’t aware that someone could try to combine Anyways… maybe a sentence that introduces
^^^ Maybe like this? |
If I understand it right, it looks like a typos of
The modified version should be clear enough for me. |
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
…ark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
Rollup merge of rust-lang#120266 - steffahn:a_rc_into_inner_docs, r=Mark-Simulacrum Improve documentation for [A]Rc::into_inner General improvements, and also aims to better encourage the reader to actually check out Arc::try_unwrap. This addresses concerns from rust-lang#106894 (comment). Rendered:  
Feature gates:
#![feature(arc_into_inner)]
,#![feature(rc_into_inner)]
This is a tracking issue for the
Arc::into_inner
method, and (for API-consistency) also anRc::into_inner
analogue.The function
Arc::into_inner(x)
serves as an atomic race-condition-free alternative toArc::try_unwrap(x).ok()
. See the ACP for more details.Public API
and the extension to
Rc
Steps / History
Arc::into_inner
for safely discardingArc
s without calling the destructor on the inner type. libs-team#162Arc::into_inner
AddArc::into_inner
for safely discardingArc
s without calling the destructor on the inner type. #106854Rc::into_inner
IntroduceRc::into_inner
, as a parallel toArc::into_inner
#109026arc_into_inner
andrc_into_inner
. #109504Unresolved Questions
Footnotes
https://std-dev-guide.rust-lang.org/feature-lifecycle/stabilization.html ↩
The text was updated successfully, but these errors were encountered: