Skip to content

Commit

Permalink
feat: 添加新api: detach_apps
Browse files Browse the repository at this point in the history
  • Loading branch information
shadow3aaa committed Oct 24, 2024
1 parent f6b32f2 commit 7b5cc1f
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion frame-analyzer/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -227,12 +227,36 @@ impl Analyzer {
}

self.map.remove(&pid).ok_or(AnalyzerError::AppNotFound)?;
self.map.remove(&pid);
self.register_poll()?;

Ok(())
}

/// Detach the Analyzer from all attached apps
///
/// # Examples
///
/// ```
/// # use frame_analyzer::Analyzer;
/// #
/// #
/// # fn main() {
/// # let _ = try_main();
/// # }
/// #
/// # fn try_main() -> anyhow::Result<()> {
/// let mut analyzer = Analyzer::new()?;
/// # let app_pid = 2;
/// analyzer.attach_app(app_pid);
/// // Do some useful work for awhile
/// analyzer.detach_apps(); // if you don't detach here, analyzer will auto detach it when itself go dropped
/// # Ok(())
/// # }
/// ```
pub fn detach_apps(&mut self) {
self.map.clear();
}

/// Attempts to wait for a frametime value on this analyzer
/// `Analyzer::recv` will always block the current thread if there is no data available
///
Expand Down

0 comments on commit 7b5cc1f

Please sign in to comment.