Skip to main content

unshare_shared

Function unshare_shared 

Source
pub unsafe fn unshare_shared<T>(payload: &mut ValuePayload) -> *mut ()
where T: Clone + PartialEq + Display + Debug + Send + Sync + 'static,
Expand description

Shared-heap unshare: detach on write. When the strong count is 1 the payload is returned unchanged (in-place, no allocation); otherwise the buffer is cloned, the word is rewritten to the private buffer, and the other clones keep the original. Either way the returned pointer addresses a buffer this word uniquely owns.

ยงSafety

The payload must co-own an Arc<T> buffer minted by Value::mint_heap_shared with one outstanding strong count per live word. The returned pointer must only be written through while this word stays the sole owner of its (possibly fresh) buffer.