generic channel: Migrate background hang monitor to GenericChannel (#39345)

Refactor the background hang monitor channels to use GenericChannel. 
Deserialization errors of `BackgroundHangMonitorControlMsg` are now
logged and ignored instead of causing a panic.

Testing: No major functional changes. Covered by BHM tests.
GenericChannel is also already widely used in servo.
Part of #38912

---------

Signed-off-by: Jonathan Schwender <schwenderjonathan@gmail.com>
This commit is contained in:
Jonathan Schwender 2025-09-17 19:11:07 +08:00 committed by GitHub
parent 6cba44e0e3
commit d848bd2759
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 36 additions and 31 deletions

View file

@ -14,6 +14,7 @@ use background_hang_monitor_api::{
BackgroundHangMonitorControlMsg, BackgroundHangMonitorExitSignal, HangAlert, HangAnnotation,
HangMonitorAlert, MonitoredComponentId, MonitoredComponentType, ScriptHangAnnotation,
};
use base::generic_channel;
use base::id::TEST_PIPELINE_ID;
use ipc_channel::ipc;
@ -24,8 +25,9 @@ fn test_hang_monitoring() {
let _lock = SERIAL.lock().unwrap();
let (background_hang_monitor_ipc_sender, background_hang_monitor_receiver) =
ipc::channel().expect("ipc channel failure");
let (_sampler_sender, sampler_receiver) = ipc::channel().expect("ipc channel failure");
generic_channel::channel().expect("ipc channel failure");
let (_sampler_sender, sampler_receiver) =
generic_channel::channel().expect("ipc channel failure");
let (background_hang_monitor_register, join_handle) = HangMonitorRegister::init(
background_hang_monitor_ipc_sender.clone(),
@ -140,8 +142,9 @@ fn test_hang_monitoring_unregister() {
let _lock = SERIAL.lock().unwrap();
let (background_hang_monitor_ipc_sender, background_hang_monitor_receiver) =
ipc::channel().expect("ipc channel failure");
let (_sampler_sender, sampler_receiver) = ipc::channel().expect("ipc channel failure");
generic_channel::channel().expect("ipc channel failure");
let (_sampler_sender, sampler_receiver) =
generic_channel::channel().expect("ipc channel failure");
let (background_hang_monitor_register, join_handle) = HangMonitorRegister::init(
background_hang_monitor_ipc_sender.clone(),
@ -225,8 +228,9 @@ fn test_hang_monitoring_exit_signal_inner(op_order: fn(&mut dyn FnMut(), &mut dy
let _lock = SERIAL.lock().unwrap();
let (background_hang_monitor_ipc_sender, _background_hang_monitor_receiver) =
ipc::channel().expect("ipc channel failure");
let (control_sender, control_receiver) = ipc::channel().expect("ipc channel failure");
generic_channel::channel().expect("ipc channel failure");
let (control_sender, control_receiver) =
generic_channel::channel().expect("ipc channel failure");
struct BHMExitSignal {
closing: Arc<AtomicBool>,