From 30f8555544481e998f52d196c5a0f4d04cbcf334 Mon Sep 17 00:00:00 2001 From: Eric Holk Date: Wed, 23 May 2012 16:34:00 -0700 Subject: [PATCH] Some comments giving some idea how to use these things. --- src/libstd/arc.rs | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 8827713d9332..fce584069dc2 100644 --- a/src/libstd/arc.rs +++ b/src/libstd/arc.rs @@ -1,5 +1,5 @@ -#[doc = "An atomically reference counted wrapper that can be used -hare immutable data between tasks."] +#[doc = "An atomically reference counted wrapper that can be used to +share immutable data between tasks."] export arc, get, clone; @@ -34,6 +34,7 @@ resource arc_destruct(data: *arc_data) { type arc = arc_destruct; +#[doc="Create an atomically reference counted wrapper."] fn arc(-data: T) -> arc { let data = ~{mut count: 1, data: data}; unsafe { @@ -43,12 +44,19 @@ fn arc(-data: T) -> arc { } } +#[doc="Access the underlying data in an atomically reference counted + wrapper."] fn get(rc: &a.arc) -> &a.T { unsafe { &(***rc).data } } +#[doc="Duplicate an atomically reference counted wrapper. + +The resulting two `arc` objects will point to the same underlying data +object. However, one of the `arc` objects can be sent to another task, +allowing them to share the underlying data."] fn clone(rc: &arc) -> arc { let data = **rc; unsafe {