auto merge of #12900 : alexcrichton/rust/rewrite-sync, r=brson
* Remove clone-ability from all primitives. All shared state will now come
from the usage of the primitives being shared, not the primitives being
inherently shareable. This allows for fewer allocations for stack-allocated
primitives.
* Add `Mutex<T>` and `RWLock<T>` which are stack-allocated primitives for purely
wrapping a piece of data
* Remove `RWArc<T>` in favor of `Arc<RWLock<T>>`
* Remove `MutexArc<T>` in favor of `Arc<Mutex<T>>`
* Shuffle around where things are located
* The `arc` module now only contains `Arc`
* A new `lock` module contains `Mutex`, `RWLock`, and `Barrier`
* A new `raw` module contains the primitive implementations of `Semaphore`,
`Mutex`, and `RWLock`
* The Deref/DerefMut trait was implemented where appropriate
* `CowArc` was removed, the functionality is now part of `Arc` and is tagged
with `#[experimental]`.
* The crate now has #[deny(missing_doc)]
* `Arc` now supports weak pointers
This is not a large-scale rewrite of the functionality contained within the
`sync` crate, but rather a shuffling of who does what an a thinner hierarchy of
ownership to allow for better composability.
This commit is contained in:
commit
6bf3fca8ff
48 changed files with 1738 additions and 2045 deletions
|
|
@ -359,7 +359,7 @@ fn main() {
|
|||
|
||||
spawn(proc() {
|
||||
let local_arc : Arc<~[f64]> = rx.recv();
|
||||
let task_numbers = local_arc.get();
|
||||
let task_numbers = &*local_arc;
|
||||
println!("{}-norm = {}", num, pnorm(task_numbers, num));
|
||||
});
|
||||
}
|
||||
|
|
@ -411,7 +411,7 @@ Each task recovers the underlying data by
|
|||
# let (tx, rx) = channel();
|
||||
# tx.send(numbers_arc.clone());
|
||||
# let local_arc : Arc<~[f64]> = rx.recv();
|
||||
let task_numbers = local_arc.get();
|
||||
let task_numbers = &*local_arc;
|
||||
# }
|
||||
~~~
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue