Skip to content

Commit

Permalink
Merge pull request OptimatistOpenSource#31 from Thaumy/into-fixed
Browse files Browse the repository at this point in the history
Add `into_fixed` fn for groups
  • Loading branch information
BrytonLee authored Mar 21, 2024
2 parents 78284a2 + cf8ac51 commit 3a5c531
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
6 changes: 5 additions & 1 deletion src/perf_event/counting/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -81,10 +81,14 @@ impl CounterGroup {

pub fn enable(self) -> io::Result<FixedCounterGroup> {
self.inner_mut().enable()?;
FixedCounterGroup::new(self.inner).wrap_ok()
self.into_fixed()
}

pub fn stat(&mut self) -> io::Result<CounterGroupStat> {
self.inner_mut().stat()
}

pub fn into_fixed(self) -> io::Result<FixedCounterGroup> {
FixedCounterGroup::new(self.inner).wrap_ok()
}
}
6 changes: 5 additions & 1 deletion src/perf_event/sampling/group/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ impl SamplerGroup {

pub fn enable(self) -> io::Result<FixedSamplerGroup> {
self.inner().enable()?;
FixedSamplerGroup::new(self.inner).wrap_ok()
self.into_fixed()
}

pub fn next_record(&self, guard: &SamplerGuard) -> Option<Record> {
Expand All @@ -84,4 +84,8 @@ impl SamplerGroup {
pub fn stat(&mut self) -> io::Result<SamplerGroupStat> {
self.inner_mut().stat()
}

pub fn into_fixed(self) -> io::Result<FixedSamplerGroup> {
FixedSamplerGroup::new(self.inner).wrap_ok()
}
}

0 comments on commit 3a5c531

Please sign in to comment.