Mark exclusive arc-related functions as unsafe. Fixes #2727.

This commit is contained in:
Eric Holk 2012-06-27 10:24:51 -07:00
parent 697f1e38d6
commit 404afcbb41
2 changed files with 13 additions and 15 deletions

View File

@ -104,19 +104,17 @@ impl methods<T: send> for exclusive<T> {
arc_destruct(self.data)
}
fn with<U>(f: fn(sys::condition, x: &T) -> U) -> U {
unsafe {
let ptr: ~arc_data<ex_data<T>> =
unsafe::reinterpret_cast(self.data);
let r = {
let rec: &ex_data<T> = &(*ptr).data;
rec.lock.lock_cond() {|c|
f(c, &rec.data)
}
};
unsafe::forget(ptr);
r
}
unsafe fn with<U>(f: fn(sys::condition, x: &T) -> U) -> U {
let ptr: ~arc_data<ex_data<T>> =
unsafe::reinterpret_cast(self.data);
let r = {
let rec: &ex_data<T> = &(*ptr).data;
rec.lock.lock_cond() {|c|
f(c, &rec.data)
}
};
unsafe::forget(ptr);
r
}
}

View File

@ -106,13 +106,13 @@ fn create_lock() -> lock_and_signal {
}
impl methods for lock_and_signal {
fn lock<T>(f: fn() -> T) -> T {
unsafe fn lock<T>(f: fn() -> T) -> T {
rustrt::rust_lock_cond_lock(self.lock);
let _r = unlock(self.lock);
f()
}
fn lock_cond<T>(f: fn(condition) -> T) -> T {
unsafe fn lock_cond<T>(f: fn(condition) -> T) -> T {
rustrt::rust_lock_cond_lock(self.lock);
let _r = unlock(self.lock);
f(condition_(self.lock))