use crate::{domain::Domain, string::StringHandle};
pub struct Task<'a>(&'a Domain);
impl<'a> Task<'a> {
pub fn begin(domain: &'a Domain, name: impl Into<StringHandle>) -> Self {
if let Some(create_fn) = unsafe { ittapi_sys::__itt_task_begin_ptr__3_0 } {
unsafe { create_fn(domain.as_ptr(), ITT_NULL, ITT_NULL, name.into().as_ptr()) };
}
Self(domain)
}
#[allow(clippy::unused_self)]
pub fn end(self) {
}
}
impl<'a> Drop for Task<'a> {
fn drop(&mut self) {
if let Some(end_fn) = unsafe { ittapi_sys::__itt_task_end_ptr__3_0 } {
unsafe { end_fn(self.0.as_ptr()) }
}
}
}
const ITT_NULL: ittapi_sys::__itt_id = ittapi_sys::__itt_id {
d1: 0,
d2: 0,
d3: 0,
};
#[cfg(test)]
mod tests {
use super::*;
#[test]
fn sanity() {
let domain = Domain::new("domain");
let name = StringHandle::new("task");
let _task = Task::begin(&domain, name);
}
}