diff options
| author | Eric Holk <eric.holk@gmail.com> | 2012-05-23 16:34:00 -0700 |
|---|---|---|
| committer | Eric Holk <eric.holk@gmail.com> | 2012-05-24 15:05:39 -0700 |
| commit | 30f8555544481e998f52d196c5a0f4d04cbcf334 (patch) | |
| tree | 9cda9595cc4bf62efcd5a99e90e93df57eaa7f3e /src/libstd | |
| parent | 5b72e52e472ca06f42700a322dc2cac4c38e05f1 (diff) | |
| download | rust-30f8555544481e998f52d196c5a0f4d04cbcf334.tar.gz rust-30f8555544481e998f52d196c5a0f4d04cbcf334.zip | |
Some comments giving some idea how to use these things.
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/arc.rs | 12 |
1 files changed, 10 insertions, 2 deletions
diff --git a/src/libstd/arc.rs b/src/libstd/arc.rs index 8827713d933..fce584069dc 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<T>(data: *arc_data<T>) { type arc<T> = arc_destruct<T>; +#[doc="Create an atomically reference counted wrapper."] fn arc<T>(-data: T) -> arc<T> { let data = ~{mut count: 1, data: data}; unsafe { @@ -43,12 +44,19 @@ fn arc<T>(-data: T) -> arc<T> { } } +#[doc="Access the underlying data in an atomically reference counted + wrapper."] fn get<T>(rc: &a.arc<T>) -> &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<T>(rc: &arc<T>) -> arc<T> { let data = **rc; unsafe { |
