Skip to content

Commit 30f8555

Browse files
committed
Some comments giving some idea how to use these things.
1 parent 5b72e52 commit 30f8555

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

src/libstd/arc.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
1-
#[doc = "An atomically reference counted wrapper that can be used
2-
hare immutable data between tasks."]
1+
#[doc = "An atomically reference counted wrapper that can be used to
2+
share immutable data between tasks."]
33

44
export arc, get, clone;
55

@@ -34,6 +34,7 @@ resource arc_destruct<T>(data: *arc_data<T>) {
3434

3535
type arc<T> = arc_destruct<T>;
3636

37+
#[doc="Create an atomically reference counted wrapper."]
3738
fn arc<T>(-data: T) -> arc<T> {
3839
let data = ~{mut count: 1, data: data};
3940
unsafe {
@@ -43,12 +44,19 @@ fn arc<T>(-data: T) -> arc<T> {
4344
}
4445
}
4546

47+
#[doc="Access the underlying data in an atomically reference counted
48+
wrapper."]
4649
fn get<T>(rc: &a.arc<T>) -> &a.T {
4750
unsafe {
4851
&(***rc).data
4952
}
5053
}
5154

55+
#[doc="Duplicate an atomically reference counted wrapper.
56+
57+
The resulting two `arc` objects will point to the same underlying data
58+
object. However, one of the `arc` objects can be sent to another task,
59+
allowing them to share the underlying data."]
5260
fn clone<T>(rc: &arc<T>) -> arc<T> {
5361
let data = **rc;
5462
unsafe {

0 commit comments

Comments
 (0)