about summary refs log tree commit diff
path: root/src/libstd/sync
AgeCommit message (Collapse)AuthorLines
2014-05-19std: Rebuild sync::deque on ArcAlex Crichton-25/+27
This also removes the `&mut self` requirement, using the correct `&self` requirement for concurrent types.
2014-05-13core: Inherit the atomics moduleAlex Crichton-795/+21
2014-05-11sync::deque: port to the new allocator APIDaniel Micay-15/+19
2014-05-11core: Remove the cast moduleAlex Crichton-33/+32
This commit revisits the `cast` module in libcore and libstd, and scrutinizes all functions inside of it. The result was to remove the `cast` module entirely, folding all functionality into the `mem` module. Specifically, this is the fate of each function in the `cast` module. * transmute - This function was moved to `mem`, but it is now marked as #[unstable]. This is due to planned changes to the `transmute` function and how it can be invoked (see the #[unstable] comment). For more information, see RFC 5 and #12898 * transmute_copy - This function was moved to `mem`, with clarification that is is not an error to invoke it with T/U that are different sizes, but rather that it is strongly discouraged. This function is now #[stable] * forget - This function was moved to `mem` and marked #[stable] * bump_box_refcount - This function was removed due to the deprecation of managed boxes as well as its questionable utility. * transmute_mut - This function was previously deprecated, and removed as part of this commit. * transmute_mut_unsafe - This function doesn't serve much of a purpose when it can be achieved with an `as` in safe code, so it was removed. * transmute_lifetime - This function was removed because it is likely a strong indication that code is incorrect in the first place. * transmute_mut_lifetime - This function was removed for the same reasons as `transmute_lifetime` * copy_lifetime - This function was moved to `mem`, but it is marked `#[unstable]` now due to the likelihood of being removed in the future if it is found to not be very useful. * copy_mut_lifetime - This function was also moved to `mem`, but had the same treatment as `copy_lifetime`. * copy_lifetime_vec - This function was removed because it is not used today, and its existence is not necessary with DST (copy_lifetime will suffice). In summary, the cast module was stripped down to these functions, and then the functions were moved to the `mem` module. transmute - #[unstable] transmute_copy - #[stable] forget - #[stable] copy_lifetime - #[unstable] copy_mut_lifetime - #[unstable] [breaking-change]
2014-05-08Handle fallout in iter, option, result, and sync::arcKevin Ballard-3/+3
API changes: - UnsafeArc::newN() returns Vec<UnsafeArc<T>>
2014-05-08Rename slice::unzip() to vec::unzip()Kevin Ballard-2/+2
unzip() has nothing to do with slices, so it belongs in vec.
2014-05-07Test fixes and rebase conflictsAlex Crichton-1/+0
2014-05-06librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, exceptPatrick Walton-19/+26
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
2014-05-02Replace most ~exprs with 'box'. #11779Brian Anderson-25/+25
2014-05-01Add debug_assert and debug_assert_eq macrosSteven Fackler-8/+4
I also switched some `assert!` calls over to `debug_assert!`. Closes #12049. RFC: 0015-assert
2014-04-18Replace all ~"" with "".to_owned()Richo Healey-4/+4
2014-04-18std: Make ~[T] no longer a growable vectorAlex Crichton-3/+5
This removes all resizability support for ~[T] vectors in preparation of DST. The only growable vector remaining is Vec<T>. In summary, the following methods from ~[T] and various functions were removed. Each method/function has an equivalent on the Vec type in std::vec unless otherwise stated. * slice::OwnedCloneableVector * slice::OwnedEqVector * slice::append * slice::append_one * slice::build (no replacement) * slice::bytes::push_bytes * slice::from_elem * slice::from_fn * slice::with_capacity * ~[T].capacity() * ~[T].clear() * ~[T].dedup() * ~[T].extend() * ~[T].grow() * ~[T].grow_fn() * ~[T].grow_set() * ~[T].insert() * ~[T].pop() * ~[T].push() * ~[T].push_all() * ~[T].push_all_move() * ~[T].remove() * ~[T].reserve() * ~[T].reserve_additional() * ~[T].reserve_exect() * ~[T].retain() * ~[T].set_len() * ~[T].shift() * ~[T].shrink_to_fit() * ~[T].swap_remove() * ~[T].truncate() * ~[T].unshift() * ~str.clear() * ~str.set_len() * ~str.truncate() Note that no other API changes were made. Existing apis that took or returned ~[T] continue to do so. [breaking-change]
2014-04-11Add more type signatures to the docs; tweak a few of them.Huon Wilson-1/+1
Someone reading the docs won't know what the types of various things are, so this adds them in a few meaningful places to help with comprehension. cc #13423.
2014-04-10std,serialize: remove some internal uses of ~[].Huon Wilson-14/+14
These are all private uses of ~[], so can easily & non-controversially be replaced with Vec.
2014-04-03Add fetch_and, fetch_or, fetch_xor to AtomicInt, AtomicUintJonathan S-1/+133
2014-03-31std: Switch field privacy as necessaryAlex Crichton-24/+24
2014-03-28Convert most code to new inner attribute syntax.Brian Anderson-2/+2
Closes #2569
2014-03-28Rename Pod into CopyFlavio Percoco-11/+11
Summary: So far, we've used the term POD "Plain Old Data" to refer to types that can be safely copied. However, this term is not consistent with the other built-in bounds that use verbs instead. This patch renames the Pod kind into Copy. RFC: 0003-opt-in-builtin-traits Test Plan: make check Reviewers: cmr Differential Revision: http://phabricator.octayn.net/D3
2014-03-24std: Unignore atomic testsBrian Anderson-4/+2
2014-03-23auto merge of #13099 : FlaPer87/rust/master, r=huonwbors-934/+0
2014-03-23Register new snapshotsFlavio Percoco-934/+0
2014-03-23iter: remove `to_owned_vec`Daniel Micay-3/+3
This needs to be removed as part of removing `~[T]`. Partial type hints are now allowed, and will remove the need to add a version of this method for `Vec<T>`. For now, this involves a few workarounds for partial type hints not completely working.
2014-03-20std: Update atomic documentation to remove 'mut'Alex Crichton-23/+23
It's all no longer necessary
2014-03-20std: Remove AtomicU64Brian Anderson-52/+0
Support for this is less universal than for word-size things; it has no users; i'd rather play it safe.
2014-03-20std: Make the generic atomics in `sync::atomics` privateBrian Anderson-10/+10
I'm not comfortable exposing public functions that purport to do atomic operations on arbitrary T.
2014-03-20std: Make the generic atomics take unsafe pointersBrian Anderson-45/+45
These mutate values behind references that are Freeze, which is not allowed.
2014-03-20std: Make atomics immutable. #11583Brian Anderson-42/+976
In Rust, the strongest guarantee that `&mut` provides is that the memory pointed to is *not aliased*, whereas `&`'s guarantees are much weaker: that the value can be aliased, and may be mutated under proper precautions (interior mutability). Our atomics though use `&mut` for mutation even while creating multiple aliases, so this changes them to use 'interior mutability', mutating through immutable references.
2014-03-20Make atomics interior Unsafe<T>Flavio Percoco-50/+60
2014-03-20Let ArcData use Unsafe<T>Flavio Percoco-4/+8
2014-03-20rename std::vec -> std::sliceDaniel Micay-8/+8
Closes #12702
2014-03-18auto merge of #12954 : brson/rust/atomicdocs, r=alexcrichtonbors-68/+393
This adds lots of docs to the atomics module. Two of the examples are using the future atomics API (relying on `Share`) and are ignored temporarily. I discovered a bug in the way AtomicBool's fetch_nand method is implemented and fixed it by using the correct value for `true`. I also fixed the implementation of AcqRel fences (it was only doing a release barrier), and made a "relaxed" fence a failure.
2014-03-18Relaxed the memory ordering on the implementation of UnsafeArcJonathan S-7/+29
2014-03-17std: Improve docs for atomics. Fix two bugsBrian Anderson-68/+393
This adds lots of docs to the atomics module. Two of the examples are using the future atomics API and are ignored temporarily. I discovered a bug in the way AtomicBool's fetch_nand method is implemented and fixed it by using the correct value for `true`. I also fixed the implementation of AcqRel fences (it was only doing a release barrier), and made a "relaxed" fence a failure.
2014-03-16Remove AtomicFlagCadence Marseille-41/+6
fixes #12943
2014-03-14fix MIPS targetJyun-Yan You-0/+4
I ignored AtomicU64 methods on MIPS target because libgcc doesn't implement MIPS32 64-bit atomic operations. Otherwise it would cause link failure.
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-18/+18
* Chan<T> => Sender<T> * Port<T> => Receiver<T> * Chan::new() => channel() * constructor returns (Sender, Receiver) instead of (Receiver, Sender) * local variables named `port` renamed to `rx` * local variables named `chan` renamed to `tx` Closes #11765
2014-02-28std: Change assert_eq!() to use {} instead of {:?}Alex Crichton-1/+1
Formatting via reflection has been a little questionable for some time now, and it's a little unfortunate that one of the standard macros will silently use reflection when you weren't expecting it. This adds small bits of code bloat to libraries, as well as not always being necessary. In light of this information, this commit switches assert_eq!() to using {} in the error message instead of {:?}. In updating existing code, there were a few error cases that I encountered: * It's impossible to define Show for [T, ..N]. I think DST will alleviate this because we can define Show for [T]. * A few types here and there just needed a #[deriving(Show)] * Type parameters needed a Show bound, I often moved this to `assert!(a == b)` * `Path` doesn't implement `Show`, so assert_eq!() cannot be used on two paths. I don't think this is much of a regression though because {:?} on paths looks awful (it's a byte array). Concretely speaking, this shaved 10K off a 656K binary. Not a lot, but sometime significant for smaller binaries.
2014-02-28std: Add cfg(test) to UnsafeArc assertionsAlex Crichton-4/+8
This is a ubiquitous type in concurrent code, and the assertions are causing significant code bloat for simple operations such as reading the pointer (injecting a failure point, etc). I am testing executable sizes with no I/O implementations (everything stubbed out to return nothing), and this took the size of a libnative executable from 328K to 207K (37% reduction in size), so I think that this is one assertion that's well worth configuring off for now.
2014-02-23std: Move intrinsics to std::intrinsics.Brian Anderson-1/+1
Issue #1457
2014-02-18Spellcheck library docs.Huon Wilson-2/+1
2014-02-15std: clean up ptr a bitCorey Richardson-1/+1
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-13/+16
This, the Nth rewrite of channels, is not a rewrite of the core logic behind channels, but rather their API usage. In the past, we had the distinction between oneshot, stream, and shared channels, but the most recent rewrite dropped oneshots in favor of streams and shared channels. This distinction of stream vs shared has shown that it's not quite what we'd like either, and this moves the `std::comm` module in the direction of "one channel to rule them all". There now remains only one Chan and one Port. This new channel is actually a hybrid oneshot/stream/shared channel under the hood in order to optimize for the use cases in question. Additionally, this also reduces the cognitive burden of having to choose between a Chan or a SharedChan in an API. My simple benchmarks show no reduction in efficiency over the existing channels today, and a 3x improvement in the oneshot case. I sadly don't have a pre-last-rewrite compiler to test out the old old oneshots, but I would imagine that the performance is comparable, but slightly slower (due to atomic reference counting). This commit also brings the bonus bugfix to channels that the pending queue of messages are all dropped when a Port disappears rather then when both the Port and the Chan disappear.
2014-02-11Shuffle around ownership in concurrent queuesAlex Crichton-267/+177
Beforehand, using a concurrent queue always mandated that the "shared state" be stored internally to the queues in order to provide a safe interface. This isn't quite as flexible as one would want in some circumstances, so instead this commit moves the queues to not containing the shared state. The queues no longer have a "default useful safe" interface, but rather a "default safe" interface (minus the useful part). The queues have to be shared manually through an Arc or some other means. This allows them to be a little more flexible at the cost of a usability hindrance. I plan on using this new flexibility to upgrade a channel to a shared channel seamlessly.
2014-02-04auto merge of #11230 : csherratt/rust/cow, r=alexcrichtonbors-0/+8
This allows patch adds a new arc type that allows for creation of copy-on-write data structures. The idea is that it is safe to mutate any data structure as long as it has only one reference to it. If there are multiple, it requires cloning of the data structure before mutation is possible.
2014-02-04Register new snapshotsAlex Crichton-190/+0
2014-02-04Replace NonCopyable usage with NoPodFlavio Percoco-20/+20
cc #10834
2014-02-03Various bug fixes and rebase conflictsAlex Crichton-1/+1
2014-02-03Add an AtomicU64 type to std::sync::atomicsAlex Crichton-32/+245
This also generalizes all atomic intrinsics over T so we'll be able to add u8 atomics if we really feel the need to (do we really want to?)
2014-02-01Make next_power_of_two generic for unsigned integersBrendan Zabarauskas-2/+2
Also rename `next_power_of_two_opt` to `checked_next_power_of_two`.
2014-01-29Removing do keyword from libstd and librustcScott Lawrence-20/+20