File tree 1 file changed +25
-1
lines changed
1 file changed +25
-1
lines changed Original file line number Diff line number Diff line change @@ -227,12 +227,36 @@ impl Analyzer {
227
227
}
228
228
229
229
self . map . remove ( & pid) . ok_or ( AnalyzerError :: AppNotFound ) ?;
230
- self . map . remove ( & pid) ;
231
230
self . register_poll ( ) ?;
232
231
233
232
Ok ( ( ) )
234
233
}
235
234
235
+ /// Detach the Analyzer from all attached apps
236
+ ///
237
+ /// # Examples
238
+ ///
239
+ /// ```
240
+ /// # use frame_analyzer::Analyzer;
241
+ /// #
242
+ /// #
243
+ /// # fn main() {
244
+ /// # let _ = try_main();
245
+ /// # }
246
+ /// #
247
+ /// # fn try_main() -> anyhow::Result<()> {
248
+ /// let mut analyzer = Analyzer::new()?;
249
+ /// # let app_pid = 2;
250
+ /// analyzer.attach_app(app_pid);
251
+ /// // Do some useful work for awhile
252
+ /// analyzer.detach_apps(); // if you don't detach here, analyzer will auto detach it when itself go dropped
253
+ /// # Ok(())
254
+ /// # }
255
+ /// ```
256
+ pub fn detach_apps ( & mut self ) {
257
+ self . map . clear ( ) ;
258
+ }
259
+
236
260
/// Attempts to wait for a frametime value on this analyzer
237
261
/// `Analyzer::recv` will always block the current thread if there is no data available
238
262
///
You can’t perform that action at this time.
0 commit comments