I have an AtomicPtr reference that gets updated and read concurrently. What is the typical paradigm for managing it? I have set it up the following way:
let new = Box::into_raw(...);
let result = aptr.compare_exchange(old, new, ...);
match result {
Ok(old) => {
// add old to some epoch based garbage collector.
}
Err(_) => {
unsafe {new.drop_in_place()};
}
}
Unfortunately the Box creation seems to leak a helluva lot of memory. Any ideas what I might be doing wrong?