track_arc_clone

Function track_arc_clone 

Source
pub fn track_arc_clone<T: ?Sized>(
    name: &str,
    source_name: &str,
    value: Arc<T>,
) -> Arc<T>
Expand description

Track Arc::clone operation.

Records an ArcClone event with the updated reference counts. Use this when cloning an Arc for thread-safe shared ownership.

§Arguments

  • name - A descriptive name for the new clone
  • source_name - Name of the Arc being cloned from
  • value - The cloned Arc (returned unchanged)

§Returns

The input Arc, unchanged.

§Examples

use std::sync::Arc;
use std::thread;

let data = track_arc_new("data", Arc::new(42));
let data_clone = track_arc_clone("thread_copy", "data", Arc::clone(&data));

let handle = thread::spawn(move || {
    println!("Value: {}", *data_clone);
});
handle.join().unwrap();