MCPcopy Create free account
hub / github.com/hashintel/hash / stop

Method stop

libs/darwin-kperf/src/sampler/thread.rs:147–169  ·  view source on GitHub ↗

Disables counting. If counting is already disabled, this is a no-op. # Errors Returns [`SamplerError`] if the kernel rejects the request. Both calls are attempted even if the first fails.

(&mut self)

Source from the content-addressed store, hash-verified

145 /// Returns [`SamplerError`] if the kernel rejects the request. Both calls
146 /// are attempted even if the first fails.
147 pub fn stop(&mut self) -> Result<(), SamplerError> {
148 if !self.running {
149 return Ok(());
150 }
151
152 let kpc_vt = self.sampler.kperf.vtable();
153
154 // Reverse order of start: thread counting first, then counting.
155 // SAFETY: passing 0 to disable counting is always safe.
156 let ret_thread_counting = unsafe { (kpc_vt.kpc_set_thread_counting)(0) };
157 // SAFETY: same as above.
158 let ret_counting = unsafe { (kpc_vt.kpc_set_counting)(0) };
159
160 self.running = false;
161
162 try_kpc(
163 ret_thread_counting,
164 SamplerError::UnableToStopThreadCounting,
165 )?;
166 try_kpc(ret_counting, SamplerError::UnableToStopCounting)?;
167
168 Ok(())
169 }
170}
171
172impl<const N: usize> Drop for ThreadSampler<'_, N> {

Callers

nothing calls this directly

Calls 3

OkInterface · 0.85
try_kpcFunction · 0.85
vtableMethod · 0.80

Tested by

no test coverage detected