fix: automatic rebuilds, num_threads for localpools (#4583)
* fix: automatic rebuilds * Fix concurrency for locapoolhandle
This commit is contained in:
1 parent
74163984be
commit
23908b9d49
5 files changed
+27
-8
No files matched your search
@@ -101,7 +101,11 @@ async fn serve_server(
|
||||
base_path().map(|s| s.to_string()),
|
||||
);
|
||||
|
||||
let task_pool = LocalPoolHandle::new(5);
|
||||
let task_pool = LocalPoolHandle::new(
|
||||
std::thread::available_parallelism()
|
||||
.map(usize::from)
|
||||
.unwrap_or(1),
|
||||
);
|
||||
let mut make_service = router.into_make_service();
|
||||
|
||||
let listener = tokio::net::TcpListener::bind(address).await.unwrap();
|
||||
|
||||
@@ -40,9 +40,11 @@ where
|
||||
static TASK_POOL: std::sync::OnceLock<LocalPoolHandle> = std::sync::OnceLock::new();
|
||||
|
||||
let pool = TASK_POOL.get_or_init(|| {
|
||||
let threads = std::thread::available_parallelism()
|
||||
.unwrap_or(std::num::NonZeroUsize::new(1).unwrap());
|
||||
LocalPoolHandle::new(threads.into())
|
||||
LocalPoolHandle::new(
|
||||
std::thread::available_parallelism()
|
||||
.map(usize::from)
|
||||
.unwrap_or(1),
|
||||
)
|
||||
});
|
||||
|
||||
pool.spawn_pinned(f)
|
||||
|
||||
Reference in new issue
Block a user