From 320ec98d65be9615b6a3fc526f7e0e10dd35ca6e Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Sun, 10 Sep 2017 12:29:33 +0200 Subject: [PATCH] Take CPU pool as dependency for State --- src/main.rs | 4 +++- src/state.rs | 4 ++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0c89d91..f957224 100644 --- a/src/main.rs +++ b/src/main.rs @@ -54,7 +54,9 @@ fn core_main() -> Result<(), Box> { .unwrap_or(8080); let db_pool = db::create_pool(db_file)?; - let state = state::State::new(db_pool); + let cpu_pool = futures_cpupool::CpuPool::new_num_cpus(); + + let state = state::State::new(db_pool, cpu_pool); let server = hyper::server::Http::new() diff --git a/src/state.rs b/src/state.rs index 18f0ce4..12b355c 100644 --- a/src/state.rs +++ b/src/state.rs @@ -18,10 +18,10 @@ pub struct State { pub type Error = Box; impl State { - pub fn new(connection_pool: Pool>) -> State { + pub fn new(connection_pool: Pool>, cpu_pool: futures_cpupool::CpuPool) -> State { State { connection_pool, - cpu_pool: futures_cpupool::CpuPool::new_num_cpus(), + cpu_pool, } }