Skip to content

Commit 152f2ea

Browse files
committed
arc.rs: make exclusive's data mutable
1 parent 9c0b469 commit 152f2ea

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/libcore/arc.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ fn clone<T: const send>(rc: &arc<T>) -> arc<T> {
8484
}
8585

8686
// An arc over mutable data that is protected by a lock.
87-
type ex_data<T: send> = {lock: sys::lock_and_signal, data: T};
87+
type ex_data<T: send> = {lock: sys::lock_and_signal, mut data: T};
8888
type exclusive<T: send> = arc_destruct<ex_data<T>>;
8989

9090
fn exclusive<T:send >(-data: T) -> exclusive<T> {
@@ -110,12 +110,12 @@ impl methods<T: send> for exclusive<T> {
110110
arc_destruct(self.data)
111111
}
112112

113-
unsafe fn with<U>(f: fn(sys::condition, x: &T) -> U) -> U {
113+
unsafe fn with<U>(f: fn(sys::condition, x: &mut T) -> U) -> U {
114114
let ptr: ~arc_data<ex_data<T>> =
115115
unsafe::reinterpret_cast(self.data);
116116
let r = {
117117
let rec: &ex_data<T> = &(*ptr).data;
118-
rec.lock.lock_cond(|c| f(c, &rec.data))
118+
rec.lock.lock_cond(|c| f(c, &mut rec.data))
119119
};
120120
unsafe::forget(ptr);
121121
r

0 commit comments

Comments
 (0)