pub struct EventSet<'nvml> {
    pub nvml: &'nvml Nvml,
    /* private fields */
}
Expand description

Handle to a set of events.

Operations on a set are not thread-safe. It does not, therefore, implement Sync.

You can get yourself an EventSet via Nvml.create_event_set.

Lifetimes are used to enforce that each EventSet instance cannot be used after the Nvml instance it was obtained from is dropped:

use nvml_wrapper::Nvml;

let nvml = Nvml::init()?;
let event_set = nvml.create_event_set()?;

drop(nvml);

// This won't compile
event_set.wait(5)?;

Fields§

§nvml: &'nvml Nvml

Implementations§

source§

impl<'nvml> EventSet<'nvml>

source

pub unsafe fn new(set: nvmlEventSet_t, nvml: &'nvml Nvml) -> Self

Create a new EventSet wrapper.

You will most likely never need to call this; see the methods available to you on the Nvml struct to get one.

§Safety

It is your responsibility to ensure that the given nvmlEventSet_t pointer is valid.

source

pub fn release_events(self) -> Result<(), NvmlError>

Use this to release the set’s events if you care about handling potential errors (the Drop implementation ignores errors!).

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • Unknown, on any unexpected error
source

pub fn wait(&self, timeout_ms: u32) -> Result<EventData<'nvml>, NvmlError>

Waits on events for the given timeout (in ms) and delivers one when it arrives.

See the high_level::event_loop module for an abstracted version of this.

This method returns immediately if an event is ready to be delivered when it is called. If no events are ready it will sleep until an event arrives, but not longer than the specified timeout. In certain conditions, this method could return before the timeout passes (e.g. when an interrupt arrives).

In the case of an XID error, the function returns the most recent XID error type seen by the system. If there are multiple XID errors generated before this method is called, the last seen XID error type will be returned for all XID error events.

§Errors
  • Uninitialized, if the library has not been successfully initialized
  • Timeout, if no event arrived in the specified timeout or an interrupt arrived
  • GpuLost, if a GPU has fallen off the bus or is otherwise inaccessible
  • Unknown, on any unexpected error
§Device Support

Supports Fermi and newer fully supported devices.

source

pub unsafe fn handle(&self) -> nvmlEventSet_t

Get the raw device handle contained in this struct

Sometimes necessary for C interop.

§Safety

This is unsafe to prevent it from being used without care. In particular, you must avoid creating a new EventSet from this handle and allowing both this EventSet and the newly created one to drop (which would result in a double-free).

Trait Implementations§

source§

impl<'nvml> Debug for EventSet<'nvml>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<'nvml> Drop for EventSet<'nvml>

This Drop implementation ignores errors! Use the .release_events() method on the EventSet struct if you care about handling them.

source§

fn drop(&mut self)

Executes the destructor for this type. Read more
source§

impl<'nvml> Send for EventSet<'nvml>

Auto Trait Implementations§

§

impl<'nvml> !RefUnwindSafe for EventSet<'nvml>

§

impl<'nvml> !Sync for EventSet<'nvml>

§

impl<'nvml> Unpin for EventSet<'nvml>

§

impl<'nvml> !UnwindSafe for EventSet<'nvml>

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.