Take CPU pool as dependency for State

This commit is contained in:
Magnus Hoff 2017-09-10 12:29:33 +02:00
parent 6fb1062376
commit 320ec98d65
2 changed files with 5 additions and 3 deletions

View file

@ -54,7 +54,9 @@ fn core_main() -> Result<(), Box<std::error::Error>> {
.unwrap_or(8080); .unwrap_or(8080);
let db_pool = db::create_pool(db_file)?; 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 = let server =
hyper::server::Http::new() hyper::server::Http::new()

View file

@ -18,10 +18,10 @@ pub struct State {
pub type Error = Box<std::error::Error + Send + Sync>; pub type Error = Box<std::error::Error + Send + Sync>;
impl State { impl State {
pub fn new(connection_pool: Pool<ConnectionManager<SqliteConnection>>) -> State { pub fn new(connection_pool: Pool<ConnectionManager<SqliteConnection>>, cpu_pool: futures_cpupool::CpuPool) -> State {
State { State {
connection_pool, connection_pool,
cpu_pool: futures_cpupool::CpuPool::new_num_cpus(), cpu_pool,
} }
} }