mirror of
https://github.com/servo/servo.git
synced 2025-07-23 07:13:52 +01:00
fix: missing thread name when spawning (#31656)
* Add missing thread name when spawning * Update namings
This commit is contained in:
parent
78fe461ff2
commit
b1debf2068
3 changed files with 36 additions and 28 deletions
|
@ -49,6 +49,7 @@ impl HangMonitorRegister {
|
|||
let (tether, tether_port) = unbounded();
|
||||
|
||||
let _ = thread::Builder::new()
|
||||
.name("BackgroundHangMonitor".to_owned())
|
||||
.spawn(move || {
|
||||
let mut monitor = BackgroundHangMonitorWorker::new(
|
||||
constellation_chan,
|
||||
|
|
|
@ -526,6 +526,7 @@ pub struct CoreResourceThreadPool {
|
|||
impl CoreResourceThreadPool {
|
||||
pub fn new(num_threads: usize) -> CoreResourceThreadPool {
|
||||
let pool = rayon::ThreadPoolBuilder::new()
|
||||
.thread_name(|i| format!("CoreResourceThread#{i}"))
|
||||
.num_threads(num_threads)
|
||||
.build()
|
||||
.unwrap();
|
||||
|
|
|
@ -291,9 +291,9 @@ impl WorkletThreadPool {
|
|||
primary_sender: primary_sender,
|
||||
hot_backup_sender: hot_backup_sender,
|
||||
cold_backup_sender: cold_backup_sender,
|
||||
control_sender_0: WorkletThread::spawn(primary_role, init.clone()),
|
||||
control_sender_1: WorkletThread::spawn(hot_backup_role, init.clone()),
|
||||
control_sender_2: WorkletThread::spawn(cold_backup_role, init),
|
||||
control_sender_0: WorkletThread::spawn(primary_role, init.clone(), 0),
|
||||
control_sender_1: WorkletThread::spawn(hot_backup_role, init.clone(), 1),
|
||||
control_sender_2: WorkletThread::spawn(cold_backup_role, init, 2),
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -464,10 +464,15 @@ impl WorkletThread {
|
|||
/// Spawn a new worklet thread, returning the channel to send it control messages.
|
||||
#[allow(unsafe_code)]
|
||||
#[allow(crown::unrooted_must_root)]
|
||||
fn spawn(role: WorkletThreadRole, init: WorkletThreadInit) -> Sender<WorkletControl> {
|
||||
fn spawn(
|
||||
role: WorkletThreadRole,
|
||||
init: WorkletThreadInit,
|
||||
thread_index: u8,
|
||||
) -> Sender<WorkletControl> {
|
||||
let (control_sender, control_receiver) = unbounded();
|
||||
// TODO: name this thread
|
||||
thread::spawn(move || {
|
||||
let _ = thread::Builder::new()
|
||||
.name(format!("Worklet#{thread_index}"))
|
||||
.spawn(move || {
|
||||
// TODO: add a new IN_WORKLET thread state?
|
||||
// TODO: set interrupt handler?
|
||||
// TODO: configure the JS runtime (e.g. discourage GC, encourage agressive JIT)
|
||||
|
@ -489,7 +494,8 @@ impl WorkletThread {
|
|||
gc_threshold: MIN_GC_THRESHOLD,
|
||||
});
|
||||
thread.run();
|
||||
});
|
||||
})
|
||||
.expect("Couldn't start worklet thread");
|
||||
control_sender
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue