Skip to content

Commit 17b08d5

Browse files
committed
---
yaml --- r: 22973 b: refs/heads/master c: 0c623c4 h: refs/heads/master i: 22971: 388fbc8 v: v3
1 parent 79c1392 commit 17b08d5

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: 241085a073805447c0ad1b55525faaddcd00bedc
2+
refs/heads/master: 0c623c4474f439c0bb85b7f91ae663d9584e7973
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libcore/arc.rs

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ fn exclusive<T:send >(-data: T) -> exclusive<T> {
9797
}
9898

9999
impl methods<T: send> for exclusive<T> {
100+
/// Duplicate an exclusive ARC. See arc::clone.
100101
fn clone() -> exclusive<T> {
101102
unsafe {
102103
// this makes me nervous...
@@ -109,6 +110,22 @@ impl methods<T: send> for exclusive<T> {
109110
arc_destruct(self.data)
110111
}
111112

113+
/**
114+
* Access the underlying mutable data with mutual exclusion from other
115+
* tasks. The argument closure will be run with the mutex locked; all
116+
* other tasks wishing to access the data will block until the closure
117+
* finishes running.
118+
*
119+
* Currently, scheduling operations (i.e., yielding, receiving on a pipe,
120+
* accessing the provided condition variable) are prohibited while inside
121+
* the exclusive. Supporting that is a work in progress.
122+
*
123+
* The reason this function is 'unsafe' is because it is possible to
124+
* construct a circular reference among multiple ARCs by mutating the
125+
* underlying data. This creates potential for deadlock, but worse, this
126+
* will guarantee a memory leak of all involved ARCs. Using exclusive
127+
* ARCs inside of other ARCs is safe in absence of circular references.
128+
*/
112129
unsafe fn with<U>(f: fn(sys::condition, x: &mut T) -> U) -> U {
113130
let ptr: ~arc_data<ex_data<T>> =
114131
unsafe::reinterpret_cast(self.data);

0 commit comments

Comments
 (0)