Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR RUST

armanriazi•rust•rc•vs•arc

Unlike [Rc<T>], Arc<T> uses atomic operations for its reference counting. This means that it is thread-safe. The disadvantage is that atomic operations are more expensive than ordinary memory accesses. 
If you are not sharing reference-counted allocations between threads, consider using [Rc<T>] for lower overhead.
[Rc<T>] is a safe default, because the compiler will catch any attempt to send an [Rc<T>] between threads. However, a library might choose Arc<T> in order to give library consumers more flexibility.
 
PREVIOUS NEXT
Tagged:
ADD COMMENT
Topic
Name
4+7 =