Struct servo_arc::Arc

source ·
#[repr(C)]
pub struct Arc<T: ?Sized> { pub(crate) p: NonNull<ArcInner<T>>, pub(crate) phantom: PhantomData<T>, }
Expand description

An atomically reference counted shared pointer

See the documentation for Arc in the standard library. Unlike the standard library Arc, this Arc does not support weak reference counting.

See the discussion in https://github.com/rust-lang/rust/pull/60594 for the usage of PhantomData.

cbindgen:derive-eq=false cbindgen:derive-neq=false

Fields

p: NonNull<ArcInner<T>>phantom: PhantomData<T>

Implementations

Construct an Arc<T>

Construct an intentionally-leaked arc.

Convert the Arc to a raw pointer, suitable for use across FFI

Note: This returns a pointer to the data T, which is offset in the allocation.

It is recommended to use RawOffsetArc for this.

Reconstruct the Arc from a raw pointer obtained from into_raw()

Note: This raw pointer will be offset in the allocation and must be preceded by the atomic count.

It is recommended to use RawOffsetArc for this

Create a new static Arc (one that won’t reference count the object) and place it in the allocation provided by the specified alloc function.

alloc must return a pointer into a static allocation suitable for storing data with the Layout passed into it. The pointer returned by alloc will not be freed.

Produce a pointer to the data that can be converted back to an Arc. This is basically an &Arc<T>, without the extra indirection. It has the benefits of an &T but also knows about the underlying refcount and can be converted into more Arc<T>s if necessary.

Temporarily converts |self| into a bonafide RawOffsetArc and exposes it to the provided callback. The refcount is not modified.

Returns the address on the heap of the Arc itself – not the T within it – for memory reporting.

If this is a static reference, this returns null.

Marks this Arc as intentionally leaked for the purposes of refcount logging.

It’s a logic error to call this more than once, but it’s not unsafe, as it’d just report negative leaks.

Test pointer equality between the two Arcs, i.e. they must be the same allocation

Makes a mutable reference to the Arc, cloning if necessary

This is functionally equivalent to Arc::make_mut from the standard library.

If this Arc is uniquely owned, make_mut() will provide a mutable reference to the contents. If not, make_mut() will create a new Arc with a copy of the contents, update this to point to it, and provide a mutable reference to its contents.

This is useful for implementing copy-on-write schemes where you wish to avoid copying things if your Arc is not shared.

Provides mutable access to the contents if the Arc is uniquely owned.

Whether or not the Arc is a static reference.

Whether or not the Arc is uniquely owned (is the refcount 1?) and not a static reference.

Creates an Arc for a HeaderSlice using the given header struct and iterator to generate the slice.

is_static indicates whether to create a static Arc.

alloc is used to get a pointer to the memory into which the dynamically sized ArcInner<HeaderSlice<H, T>> value will be written. If is_static is true, then alloc must return a pointer into some static memory allocation. If it is false, then alloc must return an allocation that can be dellocated by calling Box::from_raw::<ArcInner<HeaderSlice<H, T>>> on it.

Creates an Arc for a HeaderSlice using the given header struct and iterator to generate the slice. The resulting Arc will be fat.

Converts an Arc into a ThinArc. This consumes the Arc, so the refcount is not modified.

Converts a ThinArc into an Arc. This consumes the ThinArc, so the refcount is not modified.

Converts an Arc into a RawOffsetArc. This consumes the Arc, so the refcount is not modified.

Converts a RawOffsetArc into an Arc. This consumes the RawOffsetArc, so the refcount is not modified.

Trait Implementations

Converts this type into a shared reference of the (usually inferred) input type.
Immutably borrows from an owned value. Read more
Returns a copy of the value. Read more
Performs copy-assignment from source. Read more
Formats the value using the given formatter. Read more
Returns the “default value” for a type. Read more
The resulting type after dereferencing.
Dereferences the value.
Deserialize this value from the given Serde deserializer. Read more
Formats the value using the given formatter. Read more
Executes the destructor for this type. Read more
Converts to this type from the input type.
Feeds this value into the given Hasher. Read more
Feeds a slice of this type into the given Hasher. Read more
This method returns an Ordering between self and other. Read more
Compares and returns the maximum of two values. Read more
Compares and returns the minimum of two values. Read more
Restrict a value to a certain interval. Read more
This method tests for self and other values to be equal, and is used by ==. Read more
This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason. Read more
This method returns an ordering between self and other values if one exists. Read more
This method tests less than (for self and other) and is used by the < operator. Read more
This method tests less than or equal to (for self and other) and is used by the <= operator. Read more
This method tests greater than (for self and other) and is used by the > operator. Read more
This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Formats the value using the given formatter.
Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
Converts to this type from the input type.

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.
Creates owned data from borrowed data, usually by cloning. Read more
Uses borrowed data to replace owned data, usually by cloning. Read more
Converts the given value to a String. Read more
The type returned in the event of a conversion error.
Performs the conversion.
The type returned in the event of a conversion error.
Performs the conversion.