use std::path::Path;
use tokio::task::spawn_blocking;
use crate::error::BlktraceError;
use crate::session::{BlkTrace, BlkTraceReport, BlkTraceSession};
impl BlkTrace {
pub async fn monitor_async(path: impl AsRef<Path>) -> Result<BlkTraceSession, BlktraceError> {
let path = path.as_ref().to_owned();
spawn_blocking(move || BlkTrace::monitor(path))
.await
.map_err(|_| BlktraceError::ThreadPanicked)?
}
}
impl BlkTraceSession {
pub async fn shutdown_async(self) -> Result<BlkTraceReport, BlktraceError> {
spawn_blocking(move || self.shutdown())
.await
.map_err(|_| BlktraceError::ThreadPanicked)?
}
}