pub enum WakeUpOn {
Bytes(u64),
Samples(u64),
}
Expand description
When to wake up asynchronous iterators.
“wake up” means notifying the async runtime to schedule the asynchronous iterator’s future to be pulled in the next round.
For performance reasons, we may not want to wake up asynchronous iterators as soon as data is available. With this option we can configure the number of bytes or samples that triggers the wake up.
If we specify the Proc
instead of All
, asynchronous iterators
will be woken up when the target process exits.
§Examples
use perf_event_open::config::{Cpu, Opts, Proc, SampleOn, WakeUpOn};
use perf_event_open::count::Counter;
use perf_event_open::event::sw::Software;
let event = Software::TaskClock;
let target = (Proc::ALL, Cpu(0));
let mut opts = Opts::default();
opts.sample_on = SampleOn::Freq(1000);
// Wake up asynchronous iterators on every sample.
opts.wake_up.on = WakeUpOn::Samples(1);
let counter = Counter::new(event, target, opts).unwrap();
let sampler = counter.sampler(5).unwrap();
counter.enable().unwrap();
let mut iter = sampler.iter().into_async().unwrap();
println!("{:-?}", iter.next().await);
Variants§
Bytes(u64)
Wake up on every N bytes available.
Bytes(0)
means never wake up.
Samples(u64)
Wake up on every N samples available.
Samples(0)
means never wake up.
Trait Implementations§
Auto Trait Implementations§
impl Freeze for WakeUpOn
impl RefUnwindSafe for WakeUpOn
impl Send for WakeUpOn
impl Sync for WakeUpOn
impl Unpin for WakeUpOn
impl UnwindSafe for WakeUpOn
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more