mirror of
https://github.com/servo/servo.git
synced 2025-08-05 05:30:08 +01:00
Fix num_threads to avoid divide by zero error when running without a thread pool
Signed-off-by: teymour-aldridge <teymour.aldridge@icloud.com>
This commit is contained in:
parent
cbda5c3e3e
commit
1f38e3411d
2 changed files with 8 additions and 4 deletions
|
@ -1404,7 +1404,7 @@ impl LayoutThread {
|
||||||
let pool;
|
let pool;
|
||||||
let (thread_pool, num_threads) = if self.parallel_flag {
|
let (thread_pool, num_threads) = if self.parallel_flag {
|
||||||
pool = STYLE_THREAD_POOL.pool();
|
pool = STYLE_THREAD_POOL.pool();
|
||||||
(pool.as_ref(), STYLE_THREAD_POOL.num_threads)
|
(pool.as_ref(), STYLE_THREAD_POOL.num_threads.unwrap_or(1))
|
||||||
} else {
|
} else {
|
||||||
(None, 1)
|
(None, 1)
|
||||||
};
|
};
|
||||||
|
|
|
@ -26,8 +26,8 @@ pub struct GlobalStyleData {
|
||||||
|
|
||||||
/// Global thread pool.
|
/// Global thread pool.
|
||||||
pub struct StyleThreadPool {
|
pub struct StyleThreadPool {
|
||||||
/// How many threads parallel styling can use.
|
/// How many threads parallel styling can use. If not using a thread pool, this is set to `None`.
|
||||||
pub num_threads: usize,
|
pub num_threads: Option<usize>,
|
||||||
|
|
||||||
/// The parallel styling thread pool.
|
/// The parallel styling thread pool.
|
||||||
///
|
///
|
||||||
|
@ -160,7 +160,11 @@ lazy_static! {
|
||||||
};
|
};
|
||||||
|
|
||||||
StyleThreadPool {
|
StyleThreadPool {
|
||||||
num_threads,
|
num_threads: if num_threads > 0 {
|
||||||
|
Some(num_threads)
|
||||||
|
} else {
|
||||||
|
None
|
||||||
|
},
|
||||||
style_thread_pool: RwLock::new(pool),
|
style_thread_pool: RwLock::new(pool),
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue