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 NvmlImplementations§
Source§impl<'nvml> EventSet<'nvml>
impl<'nvml> EventSet<'nvml>
Sourcepub unsafe fn new(set: nvmlEventSet_t, nvml: &'nvml Nvml) -> Self
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.
Sourcepub fn release_events(self) -> Result<(), NvmlError>
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 initializedUnknown, on any unexpected error
Sourcepub fn wait(&self, timeout_ms: u32) -> Result<EventData<'nvml>, NvmlError>
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 initializedTimeout, if no event arrived in the specified timeout or an interrupt arrivedGpuLost, if a GPU has fallen off the bus or is otherwise inaccessibleUnknown, on any unexpected error
§Device Support
Supports Fermi and newer fully supported devices.
Sourcepub unsafe fn handle(&self) -> nvmlEventSet_t
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> Drop for EventSet<'nvml>
This Drop implementation ignores errors! Use the .release_events()
method on the EventSet struct if you care about handling them.
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.