浏览代码

use thread pool

Evan Almloff 2 年之前
父节点
当前提交
687cdf2cac
共有 2 个文件被更改,包括 4 次插入2 次删除
  1. 2 0
      packages/native-core/Cargo.toml
  2. 2 2
      packages/native-core/src/passes.rs

+ 2 - 0
packages/native-core/Cargo.toml

@@ -28,6 +28,8 @@ hashbrown = { version = "0.13.2", features = ["raw"] }
 # for parsing attributes
 lightningcss = "1.0.0-alpha.39"
 
+rayon = "1.6.1"
+
 [dev-dependencies]
 rand = "0.8.5"
 dioxus = { path = "../dioxus", version = "^0.3.0" }

+ 2 - 2
packages/native-core/src/passes.rs

@@ -390,7 +390,7 @@ pub fn resolve_passes<V: FromAnyValue + Send + Sync>(
     while !pass_indexes_remaining.is_empty() {
         let mut currently_in_use = FxHashSet::<TypeId>::default();
         let dynamically_borrowed_tree = tree.tree.dynamically_borrowed();
-        std::thread::scope(|s| {
+        rayon::in_place_scope(|s| {
             let mut i = 0;
             while i < pass_indexes_remaining.len() {
                 let passes_idx = pass_indexes_remaining[i];
@@ -414,7 +414,7 @@ pub fn resolve_passes<V: FromAnyValue + Send + Sync>(
                     let dirty_nodes = dirty_nodes.clone();
                     let nodes_updated = nodes_updated.clone();
                     let ctx = ctx.clone();
-                    s.spawn(move || {
+                    s.spawn(move |_| {
                         pass.resolve(tree_view, &dirty_nodes, &nodes_updated, &ctx);
                     });
                 } else {