ext/pf2/src/signal_scheduler.rs in pf2-0.6.0 vs ext/pf2/src/signal_scheduler.rs in pf2-0.7.0
- old
+ new
@@ -56,17 +56,19 @@
}
let profile = self.profile.try_read().unwrap();
log::debug!("Number of samples: {}", profile.samples.len());
- let serialized = if self.configuration.use_experimental_serializer {
- ProfileSerializer2::new().serialize(&profile)
+ if self.configuration.use_experimental_serializer {
+ let mut ser = ProfileSerializer2::new();
+ ser.serialize(&profile);
+ ser.to_ruby_hash()
} else {
- ProfileSerializer::serialize(&profile)
- };
- let serialized = CString::new(serialized).unwrap();
- unsafe { rb_str_new_cstr(serialized.as_ptr()) }
+ let serialized = ProfileSerializer::serialize(&profile);
+ let string = CString::new(serialized).unwrap();
+ unsafe { rb_str_new_cstr(string.as_ptr()) }
+ }
}
fn on_new_thread(&self, thread: VALUE) {
self.install_timer_to_ruby_thread(thread);
}
@@ -92,13 +94,10 @@
}
}
impl SignalScheduler {
pub fn new(configuration: &Configuration, profile: Arc<RwLock<Profile>>) -> Self {
- Self {
- configuration: configuration.clone(),
- profile,
- }
+ Self { configuration: configuration.clone(), profile }
}
// Install signal handler for profiling events to the current process.
fn install_signal_handler(&self) {
let mut sa: libc::sigaction = unsafe { mem::zeroed() };