Skip to content

Commit 1c1236d

Browse files
committed
---
yaml --- r: 31635 b: refs/heads/dist-snap c: 0c623c4 h: refs/heads/master i: 31633: cc0f7ba 31631: 1f425c1 v: v3
1 parent f252f48 commit 1c1236d

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
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: 241085a073805447c0ad1b55525faaddcd00bedc
10+
refs/heads/dist-snap: 0c623c4474f439c0bb85b7f91ae663d9584e7973
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/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)