Skip to content

Commit f58c722

Browse files
committed
---
yaml --- r: 23345 b: refs/heads/master c: 3b09c3d h: refs/heads/master i: 23343: 3f2fe68 v: v3
1 parent d7195fb commit f58c722

File tree

2 files changed

+23
-1
lines changed

2 files changed

+23
-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: 71ec545614e72b815a3685bb461c7853368b92b0
2+
refs/heads/master: 3b09c3deaa9a376d0ae40a783713ece3720ca08f
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: cd6f24f9d14ac90d167386a56e7a6ac1f0318195
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be

trunk/src/libstd/arc.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ fn clone<T: const send>(rc: &arc<T>) -> arc<T> {
9393
arc { x: unsafe { clone_shared_mutable_state(&rc.x) } }
9494
}
9595

96+
/**
97+
* Retrieve the data back out of the ARC. This function blocks until the
98+
* reference given to it is the last existing one, and then unwrap the data
99+
* instead of destroying it.
100+
*
101+
* If multiple tasks call unwrap, all but the first will fail. Do not call
102+
* unwrap from a task that holds another reference to the same ARC; it is
103+
* guaranteed to deadlock.
104+
*/
96105
fn unwrap<T: const send>(+rc: arc<T>) -> T {
97106
let arc { x: x } = rc;
98107
unsafe { unwrap_shared_mutable_state(x) }
@@ -186,6 +195,12 @@ impl<T: send> &mutex_arc<T> {
186195
}
187196
}
188197

198+
/**
199+
* Retrieves the data, blocking until all other references are dropped,
200+
* exactly as arc::unwrap.
201+
*
202+
* Will additionally fail if another task has failed while accessing the arc.
203+
*/
189204
// FIXME(#2585) make this a by-move method on the arc
190205
fn unwrap_mutex_arc<T: send>(+arc: mutex_arc<T>) -> T {
191206
let mutex_arc { x: x } = arc;
@@ -363,6 +378,13 @@ impl<T: const send> &rw_arc<T> {
363378
}
364379
}
365380
381+
/**
382+
* Retrieves the data, blocking until all other references are dropped,
383+
* exactly as arc::unwrap.
384+
*
385+
* Will additionally fail if another task has failed while accessing the arc
386+
* in write mode.
387+
*/
366388
// FIXME(#2585) make this a by-move method on the arc
367389
fn unwrap_rw_arc<T: const send>(+arc: rw_arc<T>) -> T {
368390
let rw_arc { x: x, _ } = arc;

0 commit comments

Comments
 (0)