MCPcopy Create free account
hub / github.com/Rust-GPU/rust-cuda / drop_async

Method drop_async

crates/cust/src/memory/device/device_buffer.rs:116–125  ·  view source on GitHub ↗

Enqueues an operation to free the memory backed by this [`DeviceBuffer`] on a particular stream. The stream will free the allocation as soon as it reaches the operation in the stream. You can ensure the memory is freed by synchronizing the stream. This function uses internal memory pool semantics. Async allocations will reserve memory in the default memory pool in the stream, and async frees will

(self, stream: &Stream)

Source from the content-addressed store, hash-verified

114 /// # }
115 /// ```
116 pub fn drop_async(self, stream: &Stream) -> CudaResult<()> {
117 if self.buf.is_null() {
118 return Ok(());
119 }
120 // make sure we dont run the normal destructor, otherwise a double drop will happen
121 let me = ManuallyDrop::new(self);
122 // SAFETY: we consume the box so its not possible to use the box past its drop point unless
123 // you keep around a pointer, but in that case, we cannot guarantee safety.
124 unsafe { cuda_free_async(stream, me.buf) }
125 }
126
127 /// Creates a `DeviceBuffer<T>` directly from the raw components of another device buffer.
128 ///

Callers

nothing calls this directly

Calls 3

newFunction · 0.85
cuda_free_asyncFunction · 0.85
is_nullMethod · 0.80

Tested by

no test coverage detected