@@ -93,6 +93,15 @@ fn clone<T: const send>(rc: &arc<T>) -> arc<T> {
93
93
arc { x : unsafe { clone_shared_mutable_state ( & rc. x ) } }
94
94
}
95
95
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
+ */
96
105
fn unwrap < T : const send > ( +rc : arc < T > ) -> T {
97
106
let arc { x : x } = rc;
98
107
unsafe { unwrap_shared_mutable_state ( x) }
@@ -186,6 +195,12 @@ impl<T: send> &mutex_arc<T> {
186
195
}
187
196
}
188
197
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
+ */
189
204
// FIXME(#2585) make this a by-move method on the arc
190
205
fn unwrap_mutex_arc < T : send > ( +arc : mutex_arc < T > ) -> T {
191
206
let mutex_arc { x : x } = arc;
@@ -363,6 +378,13 @@ impl<T: const send> &rw_arc<T> {
363
378
}
364
379
}
365
380
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
+ */
366
388
// FIXME(#2585) make this a by-move method on the arc
367
389
fn unwrap_rw_arc<T: const send>(+arc: rw_arc<T>) -> T {
368
390
let rw_arc { x: x, _ } = arc;
0 commit comments