summary refs log tree commit diff
path: root/src/liballoc/arc.rs
AgeCommit message (Collapse)AuthorLines
2015-09-11std: Stabilize/deprecate features for 1.4Alex Crichton-17/+13
The FCP is coming to a close and 1.4 is coming out soon, so this brings in the libs team decision for all library features this cycle. Stabilized APIs: * `<Box<str>>::into_string` * `Arc::downgrade` * `Arc::get_mut` * `Arc::make_mut` * `Arc::try_unwrap` * `Box::from_raw` * `Box::into_raw` * `CStr::to_str` * `CStr::to_string_lossy` * `CString::from_raw` * `CString::into_raw` * `IntoRawFd::into_raw_fd` * `IntoRawFd` * `IntoRawHandle::into_raw_handle` * `IntoRawHandle` * `IntoRawSocket::into_raw_socket` * `IntoRawSocket` * `Rc::downgrade` * `Rc::get_mut` * `Rc::make_mut` * `Rc::try_unwrap` * `Result::expect` * `String::into_boxed_slice` * `TcpSocket::read_timeout` * `TcpSocket::set_read_timeout` * `TcpSocket::set_write_timeout` * `TcpSocket::write_timeout` * `UdpSocket::read_timeout` * `UdpSocket::set_read_timeout` * `UdpSocket::set_write_timeout` * `UdpSocket::write_timeout` * `Vec::append` * `Vec::split_off` * `VecDeque::append` * `VecDeque::retain` * `VecDeque::split_off` * `rc::Weak::upgrade` * `rc::Weak` * `slice::Iter::as_slice` * `slice::IterMut::into_slice` * `str::CharIndices::as_str` * `str::Chars::as_str` * `str::split_at_mut` * `str::split_at` * `sync::Weak::upgrade` * `sync::Weak` * `thread::park_timeout` * `thread::sleep` Deprecated APIs * `BTreeMap::with_b` * `BTreeSet::with_b` * `Option::as_mut_slice` * `Option::as_slice` * `Result::as_mut_slice` * `Result::as_slice` * `f32::from_str_radix` * `f64::from_str_radix` Closes #27277 Closes #27718 Closes #27736 Closes #27764 Closes #27765 Closes #27766 Closes #27767 Closes #27768 Closes #27769 Closes #27771 Closes #27773 Closes #27775 Closes #27776 Closes #27785 Closes #27792 Closes #27795 Closes #27797
2015-08-22Move the Borrow and BorrowMut traits to libcore.Simon Sapin-0/+5
2015-08-22Auto merge of #27871 - alexcrichton:stabilize-libcore, r=aturonbors-2/+2
These commits move libcore into a state so that it's ready for stabilization, performing some minor cleanup: * The primitive modules for integers in the standard library were all removed from the source tree as they were just straight reexports of the libcore variants. * The `core::atomic` module now lives in `core::sync::atomic`. The `core::sync` module is otherwise empty, but ripe for expansion! * The `core::prelude::v1` module was stabilized after auditing that it is a subset of the standard library's prelude plus some primitive extension traits (char, str, and slice) * Some unstable-hacks for float parsing errors were shifted around to not use the same unstable hacks (e.g. the `flt2dec` module is now used for "privacy"). After this commit, the remaining large unstable functionality specific to libcore is: * `raw`, `intrinsics`, `nonzero`, `array`, `panicking`, `simd` -- these modules are all unstable or not reexported in the standard library, so they're just remaining in the same status quo as before * `num::Float` - this extension trait for floats needs to be audited for functionality (much of that is happening in #27823) and may also want to be renamed to `FloatExt` or `F32Ext`/`F64Ext`. * Should the extension traits for primitives be stabilized in libcore? I believe other unstable pieces are not isolated to just libcore but also affect the standard library. cc #27701
2015-08-19don't do deprecations yetAlexis Beingessner-2/+0
2015-08-19Rework Arc for FCP of #27718Alexis Beingessner-71/+118
* Add previously omitted function `Arc::try_unwrap(Self) -> Result<T, Self>` * Move `arc.downgrade()` to `Arc::downgrade(&Self)` per conventions. * Deprecate `Arc::weak_count` and `Arc::strong_count` for raciness. It is almost impossible to correctly act on these results without a CAS loop on the actual fields. * Rename `Arc::make_unique` to `Arc::make_mut` to avoid uniqueness terminology and to clarify relation to `Arc::get_mut`.
2015-08-17core: Move `atomic` into a new `sync` moduleAlex Crichton-2/+2
This mirrors the same hierarchy in the standard library.
2015-08-15alloc: Add issues for all unstable featuresAlex Crichton-8/+12
2015-08-12Remove all unstable deprecated functionalityAlex Crichton-77/+50
This commit removes all unstable and deprecated functions in the standard library. A release was recently cut (1.3) which makes this a good time for some spring cleaning of the deprecated functions.
2015-08-11Register new snapshotsAlex Crichton-3/+0
* Lots of core prelude imports removed * Makefile support for MSVC env vars and Rust crates removed * Makefile support for morestack removed
2015-08-09Replace many uses of `mem::transmute` with more specific functionsTobias Bucher-1/+1
The replacements are functions that usually use a single `mem::transmute` in their body and restrict input and output via more concrete types than `T` and `U`. Worth noting are the `transmute` functions for slices and the `from_utf8*` family for mutable slices. Additionally, `mem::transmute` was often used for casting raw pointers, when you can already cast raw pointers just fine with `as`.
2015-08-03syntax: Implement #![no_core]Alex Crichton-1/+2
This commit is an implementation of [RFC 1184][rfc] which tweaks the behavior of the `#![no_std]` attribute and adds a new `#![no_core]` attribute. The `#![no_std]` attribute now injects `extern crate core` at the top of the crate as well as the libcore prelude into all modules (in the same manner as the standard library's prelude). The `#![no_core]` attribute disables both std and core injection. [rfc]: https://github.com/rust-lang/rfcs/pull/1184
2015-07-30Auto merge of #27174 - Gankro:rc-sat, r=alexcrichtonbors-4/+26
See https://internals.rust-lang.org/t/rc-is-unsafe-mostly-on-32-bit-targets-due-to-overflow/2120 for detailed discussion of this problem.
2015-07-29make Arc mem::forget safeAlexis Beingessner-4/+26
2015-07-27Show appropriate feature flags in docsSteve Klabnik-6/+12
2015-07-03Fix 'Relaaxed' typo in code commentCorey Farwell-1/+1
2015-07-03Auto merge of #26610 - aturon:fix_make_unique, r=alexcrichtonbors-79/+177
This commit resolves the race condition in the `get_mut` and `make_unique` functions, which arose through interaction with weak pointers. The basic strategy is to "lock" the weak pointer count when trying to establish uniqueness, by reusing the field as a simple spinlock. The overhead for normal use of `Arc` is expected to be minimal -- it will be *none* when only strong pointers are used, and only requires a move from atomic increment to CAS for usage of weak pointers. The commit also removes the `unsafe` and deprecated status of these functions. Closes #24880 r? @alexcrichton cc @metajack @SimonSapin @Ms2ger
2015-07-02Fix race condition in Arc's get_mut and make_unqiueAaron Turon-79/+177
This commit resolves the race condition in the `get_mut` and `make_unique` functions, which arose through interaction with weak pointers. The basic strategy is to "lock" the weak pointer count when trying to establish uniqueness, by reusing the field as a simple spinlock. The overhead for normal use of `Arc` is expected to be minimal -- it will be *none* when only strong pointers are used, and only requires a move from atomic increment to CAS for usage of weak pointers. The commit also removes the `unsafe` and deprecated status of these functions. Along the way, the commit also improves several memory orderings, and adds commentary about why various orderings suffice.
2015-07-01Implement CoerceUnsized for arc::WeakRemi Rampin-0/+2
2015-06-24Make `align_of` behave like `min_align_of`.Huon Wilson-3/+3
This removes a footgun, since it is a reasonable assumption to make that pointers to `T` will be aligned to `align_of::<T>()`. This also matches the behaviour of C/C++. `min_align_of` is now deprecated. Closes #21611.
2015-06-17More test fixes and fallout of stability changesAlex Crichton-1/+1
2015-06-17std: Move free-functions to associated functionsAlex Crichton-4/+22
This commit moves the free functions in the `rc`, `arc`, and `boxed` modules to associated functions on their respective types, following the recent trend towards this pattern. The previous free functions are all left in-place with `#[deprecated]` pointers towards the new locations. This commit also deprecates `arc::get_mut` and `Arc::make_unique` with no replacement as they are racy in the face of weak pointers.
2015-06-17Fallout in tests and docs from feature renamingsAlex Crichton-10/+10
2015-06-17alloc: Split apart the global `alloc` featureAlex Crichton-8/+8
2015-06-09Revert "Added AsRef implementations for Arc and Rc"Alex Crichton-9/+0
This reverts commit 7f3ae0aa26d24100379ae0f3eef29916a32f4e79.
2015-06-06Remove many unneeded feature annotations in the docsSteve Klabnik-3/+0
When things get stabilized, they don't always have their docs updated to remove the gate.
2015-06-04Added AsRef implementations for Arc and RcMarkus Westerlind-0/+9
2015-05-30Mark Arc function get_mut and method make_unique unsafeUlrik Sverdrup-35/+56
This is a temporary mitigation for issue #24880 which points out that these functions are racy in a particular situation where weak pointers exist. To mitigate this, mark the functions unsafe until this can be fixed or another decision is made. This is a breaking change to unstable API, because the new version requires an `unsafe` block. Review carefully if weak pointers may race for any uses of this API and consider abandoning it. [breaking-change]
2015-05-19Fix rebase conflictsAriel Ben-Yehuda-2/+6
2015-05-17Make `Arc` support DSTsP1start-36/+50
2015-05-09Squeeze the last bits of `task`s in documentation in favor of `thread`Barosl Lee-4/+4
An automated script was run against the `.rs` and `.md` files, subsituting every occurrence of `task` with `thread`. In the `.rs` files, only the texts in the comment blocks were affected.
2015-04-28Register new snapshotsTamir Duberstein-2/+0
2015-04-22Relax bounds on Default implementation for Arc.Ulrik Sverdrup-1/+1
Send + Sync are overly restrictive, follow other traits for Arc.
2015-04-21rollup merge of #24541: alexcrichton/issue-24538Alex Crichton-1/+0
This is an implementation of [RFC 1030][rfc] which adds these traits to the prelude and additionally removes all inherent `into_iter` methods on collections in favor of the trait implementation (which is now accessible by default). [rfc]: https://github.com/rust-lang/rfcs/pull/1030 This is technically a breaking change due to the prelude additions and removal of inherent methods, but it is expected that essentially no code breaks in practice. [breaking-change] Closes #24538
2015-04-20Simplify alloc::arc::Arc example in doc-commentCorey Farwell-1/+1
As far as I can tell, this conversion to integer to floating point does not need to happen and is beside the point
2015-04-17std: Add Default/IntoIterator/ToOwned to the preludeAlex Crichton-1/+0
This is an implementation of [RFC 1030][rfc] which adds these traits to the prelude and additionally removes all inherent `into_iter` methods on collections in favor of the trait implementation (which is now accessible by default). [rfc]: https://github.com/rust-lang/rfcs/pull/1030 This is technically a breaking change due to the prelude additions and removal of inherent methods, but it is expected that essentially no code breaks in practice. [breaking-change] Closes #24538
2015-04-15Fix some typos.Ms2ger-1/+1
2015-04-07alloc: impl fmt::Pointer for Rc, Arc and BoxRicho Healey-0/+7
Closes #24091
2015-04-04Removed explicit lifetimes for `get_mut`. Fixed the doc test.Dzmitry Malyshau-1/+3
2015-04-04Renamed Arc::try_unique to get_mutDzmitry Malyshau-23/+21
2015-04-04Rollup merge of #23997 - richo:typos, r=huonwManish Goregaokar-1/+1
Kinda hoped I'd spot something else for this PR, but then didn't.
2015-04-02liballoc: fix typoRicho Healey-1/+1
2015-04-01rollup merge of #23176: huonw/rm-boundsAlex Crichton-2/+2
2015-04-01Test fixes and rebase conflicts, round 1Alex Crichton-1/+4
2015-04-02Rollup merge of #23844 - kvark:try_unique, r=alexcrichtonManish Goregaokar-6/+50
While trying to implement parallel ECS processing, I stumbled upon the need to mutate `Arc` contents. The only existed method that allowed that was `make_unique`, but it has issues: - it may clone the data as if nothing happened, where the program may just need to crash - it forces `Clone` bound, which I don't have The new `try_unique` allows accessing the contents mutably without `Clone` bound and error out if the pointer is not unique.
2015-03-31Added Arc::try_uniqueDzmitry Malyshau-6/+50
2015-03-31replace deprecated as_slice()Emeliov Dmitrii-1/+1
2015-03-28Rollup merge of #23803 - richo:unused-braces, r=ManishearthManish Goregaokar-1/+1
Pretty much what it says on the tin.
2015-03-28cleanup: Remove unused braces in use statementsRicho Healey-1/+1
2015-03-27rollup merge of #23775: alexcrichton/fix-flaky-testAlex Crichton-2/+2
Windows gets quite unhappy when a thread fails while the main thread is exiting, frequently leading to process deadlock. This has been causing quite a few deadlocks on the windows bots recently. The child threads are presumably failing because the `println!` is failing due to the main thread being shut down.
2015-03-27rollup merge of #23743: Adenilson/addInfoArcClone01Alex Crichton-0/+3
Adding more information about the behavior of Arc/Rc when you perform a clone() call.