Skip to content

Commit

Permalink
auto merge of #10055 : pcwalton/rust/arc-clone-inline, r=alexcrichton
Browse files Browse the repository at this point in the history
  • Loading branch information
bors committed Oct 25, 2013
2 parents 3f5b221 + b13415c commit b0c4752
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -117,10 +117,12 @@ pub struct Arc<T> { priv x: UnsafeArc<T> }
*/
impl<T:Freeze+Send> Arc<T> {
/// Create an atomically reference counted wrapper.
#[inline]
pub fn new(data: T) -> Arc<T> {
Arc { x: UnsafeArc::new(data) }
}

#[inline]
pub fn get<'a>(&'a self) -> &'a T {
unsafe { &*self.x.get_immut() }
}
Expand Down Expand Up @@ -148,6 +150,7 @@ impl<T:Freeze + Send> Clone for Arc<T> {
* object. However, one of the `arc` objects can be sent to another task,
* allowing them to share the underlying data.
*/
#[inline]
fn clone(&self) -> Arc<T> {
Arc { x: self.x.clone() }
}
Expand All @@ -167,6 +170,7 @@ pub struct MutexArc<T> { priv x: UnsafeArc<MutexArcInner<T>> }

impl<T:Send> Clone for MutexArc<T> {
/// Duplicate a mutex-protected Arc. See arc::clone for more details.
#[inline]
fn clone(&self) -> MutexArc<T> {
// NB: Cloning the underlying mutex is not necessary. Its reference
// count would be exactly the same as the shared state's.
Expand Down Expand Up @@ -349,6 +353,7 @@ pub struct RWArc<T> {

impl<T:Freeze + Send> Clone for RWArc<T> {
/// Duplicate a rwlock-protected Arc. See arc::clone for more details.
#[inline]
fn clone(&self) -> RWArc<T> {
RWArc { x: self.x.clone() }
}
Expand Down

0 comments on commit b0c4752

Please sign in to comment.