Skip to content

Commit 6bf3fca

Browse files
committed
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.
2 parents bcaaffb + 218461d commit 6bf3fca

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

48 files changed

+1727
-2034
lines changed

src/compiletest/compiletest.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
#[feature(phase)];
1313

1414
#[allow(non_camel_case_types)];
15-
#[allow(deprecated_owned_vector)]; // NOTE: remove after stage0
1615
#[deny(warnings)];
1716

1817
extern crate test;

src/doc/guide-tasks.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ fn main() {
359359
360360
spawn(proc() {
361361
let local_arc : Arc<~[f64]> = rx.recv();
362-
let task_numbers = local_arc.get();
362+
let task_numbers = &*local_arc;
363363
println!("{}-norm = {}", num, pnorm(task_numbers, num));
364364
});
365365
}
@@ -411,7 +411,7 @@ Each task recovers the underlying data by
411411
# let (tx, rx) = channel();
412412
# tx.send(numbers_arc.clone());
413413
# let local_arc : Arc<~[f64]> = rx.recv();
414-
let task_numbers = local_arc.get();
414+
let task_numbers = &*local_arc;
415415
# }
416416
~~~
417417

src/driver/driver.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ extern crate this = "rustdoc";
1414
#[cfg(rustc)]
1515
extern crate this = "rustc";
1616

17-
#[cfg(not(stage0))]
1817
fn main() { this::main() }
19-
20-
#[cfg(stage0)]
21-
#[start]
22-
fn start(argc: int, argv: **u8) -> int { native::start(argc, argv, this::main) }

src/etc/licenseck.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@
4141
"libstd/sync/mpsc_queue.rs", # BSD
4242
"libstd/sync/spsc_queue.rs", # BSD
4343
"libstd/sync/mpmc_bounded_queue.rs", # BSD
44-
"libsync/sync/mpsc_intrusive.rs", # BSD
44+
"libsync/mpsc_intrusive.rs", # BSD
4545
]
4646

4747
def check_license(name, contents):

src/libgreen/lib.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -207,16 +207,6 @@ pub mod sleeper_list;
207207
pub mod stack;
208208
pub mod task;
209209

210-
#[lang = "start"]
211-
#[cfg(not(test), stage0)]
212-
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
213-
use std::cast;
214-
start(argc, argv, proc() {
215-
let main: extern "Rust" fn() = unsafe { cast::transmute(main) };
216-
main();
217-
})
218-
}
219-
220210
/// Set up a default runtime configuration, given compiler-supplied arguments.
221211
///
222212
/// This function will block until the entire pool of M:N schedulers have

src/libgreen/simple.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl Runtime for SimpleTask {
4040
// See libnative/task.rs for what's going on here with the `awoken`
4141
// field and the while loop around wait()
4242
unsafe {
43-
let mut guard = (*me).lock.lock();
43+
let guard = (*me).lock.lock();
4444
(*me).awoken = false;
4545
match f(task) {
4646
Ok(()) => {
@@ -60,7 +60,7 @@ impl Runtime for SimpleTask {
6060
to_wake.put_runtime(self as ~Runtime);
6161
unsafe {
6262
cast::forget(to_wake);
63-
let mut guard = (*me).lock.lock();
63+
let guard = (*me).lock.lock();
6464
(*me).awoken = true;
6565
guard.signal();
6666
}

src/libnative/io/timer_helper.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn send(req: Req) {
7575
fn shutdown() {
7676
// Request a shutdown, and then wait for the task to exit
7777
unsafe {
78-
let mut guard = TIMER_HELPER_EXIT.lock();
78+
let guard = TIMER_HELPER_EXIT.lock();
7979
send(Shutdown);
8080
guard.wait();
8181
drop(guard);

src/libnative/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ static OS_DEFAULT_STACK_ESTIMATE: uint = 1 << 20;
6969
static OS_DEFAULT_STACK_ESTIMATE: uint = 2 * (1 << 20);
7070

7171
#[lang = "start"]
72-
#[cfg(not(test), not(stage0))]
72+
#[cfg(not(test))]
7373
pub fn lang_start(main: *u8, argc: int, argv: **u8) -> int {
7474
use std::cast;
7575
start(argc, argv, proc() {

src/libnative/task.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ impl rt::Runtime for Ops {
190190
let task = BlockedTask::block(cur_task);
191191

192192
if times == 1 {
193-
let mut guard = (*me).lock.lock();
193+
let guard = (*me).lock.lock();
194194
(*me).awoken = false;
195195
match f(task) {
196196
Ok(()) => {
@@ -202,7 +202,7 @@ impl rt::Runtime for Ops {
202202
}
203203
} else {
204204
let mut iter = task.make_selectable(times);
205-
let mut guard = (*me).lock.lock();
205+
let guard = (*me).lock.lock();
206206
(*me).awoken = false;
207207
let success = iter.all(|task| {
208208
match f(task) {
@@ -232,7 +232,7 @@ impl rt::Runtime for Ops {
232232
let me = &mut *self as *mut Ops;
233233
to_wake.put_runtime(self as ~rt::Runtime);
234234
cast::forget(to_wake);
235-
let mut guard = (*me).lock.lock();
235+
let guard = (*me).lock.lock();
236236
(*me).awoken = true;
237237
guard.signal();
238238
}

src/librustdoc/html/format.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -208,8 +208,8 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
208208
let loc = loc.unwrap();
209209

210210
local_data::get(cache_key, |cache| {
211-
let cache = cache.unwrap().get();
212-
let abs_root = root(cache, loc.as_slice());
211+
let cache = cache.unwrap();
212+
let abs_root = root(&**cache, loc.as_slice());
213213
let rel_root = match path.segments.get(0).name.as_slice() {
214214
"self" => Some(~"./"),
215215
_ => None,
@@ -241,7 +241,7 @@ fn path(w: &mut io::Writer, path: &clean::Path, print_all: bool,
241241
}
242242
}
243243

244-
match info(cache) {
244+
match info(&**cache) {
245245
// This is a documented path, link to it!
246246
Some((ref fqp, shortty)) if abs_root.is_some() => {
247247
let mut url = abs_root.unwrap();
@@ -301,7 +301,7 @@ impl fmt::Show for clean::Type {
301301
match *self {
302302
clean::TyParamBinder(id) | clean::Generic(id) => {
303303
local_data::get(cache_key, |cache| {
304-
let m = cache.unwrap().get();
304+
let m = cache.unwrap();
305305
f.buf.write(m.typarams.get(&id).as_bytes())
306306
})
307307
}

0 commit comments

Comments
 (0)