Crate servo_arc

source ·
Expand description

Fork of Arc for Servo. This has the following advantages over std::sync::Arc:

  • We don’t waste storage on the weak reference count.
  • We don’t do extra RMU operations to handle the possibility of weak references.
  • We can experiment with arena allocation (todo).
  • We can add methods to support our custom use cases 1.
  • We have support for dynamically-sized types (see from_header_and_iter).
  • We have support for thin arcs to unsized types (see ThinArc).
  • We have support for references to static data, which don’t do any refcounting.


  • An atomically reference counted shared pointer
  • A “borrowed Arc”. This is a pointer to a T that is known to have been allocated within an Arc.
  • A tagged union that can represent Arc<A> or Arc<B> while only consuming a single word. The type is also NonNull, and thus can be stored in an Option without increasing size.
  • Structure to allow Arc-managing some fixed-sized data and a variably-sized slice in a single allocation.
  • Header data with an inline length. Consumers that use HeaderWithLength as the Header type in HeaderSlice can take advantage of ThinArc.
  • A “thin” Arc containing dynamically sized data
  • An Arc that is known to be uniquely owned