about summary refs log tree commit diff
path: root/src/libsync/sync
AgeCommit message (Collapse)AuthorLines
2014-03-23sync: Rewrite the base primitivesAlex Crichton-1330/+0
This commit rewrites the core primitives of the sync library: Mutex, RWLock, and Semaphore. These primitives now have updated, more modernized apis: * Guards are returned instead of locking with closures. All condition variables have moved inside the guards and extraneous methods have been removed. * Downgrading on an rwlock is now done through the guard instead of the rwlock itself. These types are meant to be general locks, not locks of an internal type (for external usage). New types will be introduced for locking shared data.
2014-03-23sync: Move Once to using &selfAlex Crichton-168/+0
Similarly to the rest of the previous commits, this moves the once primitive to using &self instead of &mut self for proper sharing among many threads now.
2014-03-23sync: Move the Mutex type to using &selfAlex Crichton-558/+0
This also uses the Unsafe type for any interior mutability in the type to avoid transmutes.
2014-03-23sync: Move the concurrent queue to using &selfAlex Crichton-139/+0
This commit also lifts it up a level in the module hierarchy in the soon-to-come reorganization of libsync.
2014-03-22Remove outdated and unnecessary std::vec_ng::Vec imports.Huon Wilson-1/+0
(And fix some tests.)
2014-03-21test: Make manual changes to deal with the fallout from removal ofPatrick Walton-12/+13
`~[T]` in test, libgetopts, compiletest, librustdoc, and libnum.
2014-03-13std: Rename Chan/Port types and constructorAlex Crichton-180/+83
* 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-03-06fix typos with with repeated words, just like this sentence.Kang Seonghoon-1/+1
2014-03-04Rename all variables that have uppercase characters in their names to use ↵Palmer Cox-3/+3
only lowercase characters
2014-03-04Cleaned up `std::any`Marvin Löbel-0/+7
- Added `TraitObject` representation to `std::raw`. - Added doc to `std::raw`. - Removed `Any::as_void_ptr()` and `Any::as_mut_void_ptr()` methods as they are uneccessary now after the removal of headers on owned boxes. This reduces the number of virtual calls needed. - Made the `..Ext` implementations work directly with the repr of a trait object. - Removed `Any`-related traits from the prelude. - Added bench for `Any`
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-18Spellcheck library docs.Huon Wilson-1/+1
2014-02-15auto merge of #12235 : huonw/rust/raii-lock, r=alexcrichtonbors-5/+6
- adds a `LockGuard` type returned by `.lock` and `.trylock` that unlocks the mutex in the destructor - renames `mutex::Mutex` to `StaticNativeMutex` - adds a `NativeMutex` type with a destructor - removes `LittleLock` - adds `#[must_use]` to `sync::mutex::Guard` to remind people to use it
2014-02-16sync: Add `#[must_use]` to the Mutex guard.Huon Wilson-0/+1
This helps people remember to save the return value to keep the mutex locked as appropriate.
2014-02-16std: Rename unstable::mutex::Mutex to StaticNativeMutex.Huon Wilson-3/+3
This better reflects its purpose and design.
2014-02-16std: add an RAII unlocker to Mutex.Huon Wilson-2/+2
This automatically unlocks its lock when it goes out of scope, and provides a safe(ish) method to call .wait.
2014-02-14extern mod => extern crateAlex Crichton-1/+1
This was previously implemented, and it just needed a snapshot to go through
2014-02-11Rewrite channels yet again for upgradeabilityAlex Crichton-4/+4
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-11Move replace and swap to std::mem. Get rid of std::utilEdward Wang-2/+2
Also move Void to std::any, move drop to std::mem and reexport in prelude.
2014-02-05move concurrent stuff from libextra to libsyncJeremyLetang-0/+2284