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

Method drop

crates/cust/src/event.rs:329–344  ·  view source on GitHub ↗

Destroy an `Event` returning an error. Destroying an event can return errors from previous asynchronous work. This function destroys the given event and returns the error and the un-destroyed event on failure. # Example ``` # use cust::*; # use std::error::Error; # fn main() -> Result<(), Box > { # let _context = quick_init()?; use cust::event::{Event, EventFlags}; let event = Event:

(mut event: Event)

Source from the content-addressed store, hash-verified

327 /// # }
328 /// ```
329 pub fn drop(mut event: Event) -> DropResult<Event> {
330 if event.0.is_null() {
331 return Ok(());
332 }
333
334 unsafe {
335 let inner = mem::replace(&mut event.0, ptr::null_mut());
336 match cuEventDestroy_v2(inner).to_result() {
337 Ok(()) => {
338 mem::forget(event);
339 Ok(())
340 }
341 Err(e) => Err((e, Event(inner))),
342 }
343 }
344 }
345}
346
347impl Drop for Event {

Callers

nothing calls this directly

Calls 3

EventClass · 0.85
is_nullMethod · 0.80
to_resultMethod · 0.45

Tested by

no test coverage detected