]> git.lizzy.rs Git - rust.git/blobdiff - src/liballoc/arc.rs
auto merge of #15999 : Kimundi/rust/fix_folder, r=nikomatsakis
[rust.git] / src / liballoc / arc.rs
index 38ed511c4589a5004a12b6510fff04bde660d845..bf477781aabf6a8207d61956fc5682013783bb46 100644 (file)
@@ -8,10 +8,10 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
-/*!
- * Concurrency-enabled mechanisms for sharing mutable and/or immutable state
- * between tasks.
- */
+#![stable]
+
+//! Concurrency-enabled mechanisms for sharing mutable and/or immutable state
+//! between tasks.
 
 use core::atomics;
 use core::clone::Clone;
@@ -51,6 +51,7 @@
 /// }
 /// ```
 #[unsafe_no_drop_flag]
+#[stable]
 pub struct Arc<T> {
     // FIXME #12808: strange name to try to avoid interfering with
     // field accesses of the contained type via Deref
@@ -62,6 +63,7 @@ pub struct Arc<T> {
 /// Weak pointers will not keep the data inside of the `Arc` alive, and can be
 /// used to break cycles between `Arc` pointers.
 #[unsafe_no_drop_flag]
+#[experimental = "Weak pointers may not belong in this module."]
 pub struct Weak<T> {
     // FIXME #12808: strange name to try to avoid interfering with
     // field accesses of the contained type via Deref
@@ -77,6 +79,7 @@ struct ArcInner<T> {
 impl<T: Share + Send> Arc<T> {
     /// Create an atomically reference counted wrapper.
     #[inline]
+    #[stable]
     pub fn new(data: T) -> Arc<T> {
         // Start the weak pointer count as 1 which is the weak pointer that's
         // held by all the strong pointers (kinda), see std/rc.rs for more info
@@ -89,7 +92,7 @@ pub fn new(data: T) -> Arc<T> {
     }
 
     #[inline]
-    fn inner<'a>(&'a self) -> &'a ArcInner<T> {
+    fn inner(&self) -> &ArcInner<T> {
         // This unsafety is ok because while this arc is alive we're guaranteed
         // that the inner pointer is valid. Furthermore, we know that the
         // `ArcInner` structure itself is `Share` because the inner data is
@@ -103,6 +106,7 @@ fn inner<'a>(&'a self) -> &'a ArcInner<T> {
     /// Weak pointers will not keep the data alive. Once all strong references
     /// to the underlying data have been dropped, the data itself will be
     /// destroyed.
+    #[experimental = "Weak pointers may not belong in this module."]
     pub fn downgrade(&self) -> Weak<T> {
         // See the clone() impl for why this is relaxed
         self.inner().weak.fetch_add(1, atomics::Relaxed);
@@ -110,7 +114,7 @@ pub fn downgrade(&self) -> Weak<T> {
     }
 }
 
-#[unstable]
+#[unstable = "waiting on stability of Clone"]
 impl<T: Share + Send> Clone for Arc<T> {
     /// Duplicate an atomically reference counted wrapper.
     ///
@@ -135,9 +139,10 @@ fn clone(&self) -> Arc<T> {
     }
 }
 
+#[experimental = "Deref is experimental."]
 impl<T: Send + Share> Deref<T> for Arc<T> {
     #[inline]
-    fn deref<'a>(&'a self) -> &'a T {
+    fn deref(&self) -> &T {
         &self.inner().data
     }
 }
@@ -150,7 +155,7 @@ impl<T: Send + Share + Clone> Arc<T> {
     /// data is cloned if the reference count is greater than one.
     #[inline]
     #[experimental]
-    pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
+    pub fn make_unique(&mut self) -> &mut T {
         // Note that we hold a strong reference, which also counts as
         // a weak reference, so we only clone if there is an
         // additional reference of either kind.
@@ -169,6 +174,7 @@ pub fn make_unique<'a>(&'a mut self) -> &'a mut T {
 }
 
 #[unsafe_destructor]
+#[experimental = "waiting on stability of Drop"]
 impl<T: Share + Send> Drop for Arc<T> {
     fn drop(&mut self) {
         // This structure has #[unsafe_no_drop_flag], so this drop glue may run
@@ -185,7 +191,7 @@ fn drop(&mut self) {
         // deletion of the data. Because it is marked `Release`, the
         // decreasing of the reference count synchronizes with this `Acquire`
         // fence. This means that use of the data happens before decreasing
-        // the refernce count, which happens before this fence, which
+        // the reference count, which happens before this fence, which
         // happens before the deletion of the data.
         //
         // As explained in the [Boost documentation][1],
@@ -212,6 +218,7 @@ fn drop(&mut self) {
     }
 }
 
+#[experimental = "Weak pointers may not belong in this module."]
 impl<T: Share + Send> Weak<T> {
     /// Attempts to upgrade this weak reference to a strong reference.
     ///
@@ -231,13 +238,13 @@ pub fn upgrade(&self) -> Option<Arc<T>> {
     }
 
     #[inline]
-    fn inner<'a>(&'a self) -> &'a ArcInner<T> {
+    fn inner(&self) -> &ArcInner<T> {
         // See comments above for why this is "safe"
         unsafe { &*self._ptr }
     }
 }
 
-#[unstable]
+#[experimental = "Weak pointers may not belong in this module."]
 impl<T: Share + Send> Clone for Weak<T> {
     #[inline]
     fn clone(&self) -> Weak<T> {
@@ -248,6 +255,7 @@ fn clone(&self) -> Weak<T> {
 }
 
 #[unsafe_destructor]
+#[experimental = "Weak pointers may not belong in this module."]
 impl<T: Share + Send> Drop for Weak<T> {
     fn drop(&mut self) {
         // see comments above for why this check is here
@@ -268,6 +276,7 @@ fn drop(&mut self) {
 #[allow(experimental)]
 mod tests {
     use std::clone::Clone;
+    use std::collections::MutableSeq;
     use std::comm::channel;
     use std::mem::drop;
     use std::ops::Drop;