Skip to content

Commit 59eea6c

Browse files
committed
add comment about rendering threadpool shutdown
1 parent 6f42541 commit 59eea6c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

src/web/page/templates.rs

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,15 @@ const TEMPLATES_DIRECTORY: &str = "templates";
1818
#[derive(Debug)]
1919
pub(crate) struct TemplateData {
2020
pub templates: Tera,
21+
/// rendering threadpool for CPU intensive rendering.
22+
/// When the app is shut down, the pool won't wait
23+
/// for pending tasks in this pool.
24+
/// In the case of rendering, this is what we want.
25+
/// See also https://github.com/rayon-rs/rayon/issues/688.
26+
///
27+
/// This is better than using `tokio::spawn_blocking` because
28+
/// tokio will wait until all tasks are finished when shutting
29+
/// down.
2130
rendering_threadpool: rayon::ThreadPool,
2231
}
2332

0 commit comments

Comments
 (0)