use stable async-cpupool

This commit is contained in:
asonix 2023-11-25 21:17:59 -06:00
parent 4383357abe
commit e4f665d75f
4 changed files with 8 additions and 8 deletions

3
Cargo.lock generated
View file

@ -467,7 +467,8 @@ checksum = "bddcadddf5e9015d310179a59bb28c4d4b9920ad0f11e8e14dbadf654890c9a6"
[[package]]
name = "async-cpupool"
version = "0.1.0"
source = "git+https://git.asonix.dog/safe-async/async-cpupool#2884d854fff83e96ad70b8dc06e947377d53e1b7"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba06506d5e5f2e45254bfb3175d5ca14b7dbb817cf0651cc2cc3a8b18a12c5a5"
dependencies = [
"flume",
"metrics",

View file

@ -28,7 +28,7 @@ actix-webfinger = { version = "0.5.0", default-features = false }
activitystreams = "0.7.0-alpha.25"
activitystreams-ext = "0.1.0-alpha.3"
ammonia = "3.1.0"
async-cpupool = { version = "0.1.0", git = "https://git.asonix.dog/safe-async/async-cpupool" }
async-cpupool = "0.1.0"
bcrypt = "0.15"
base64 = "0.21"
clap = { version = "4.0.0", features = ["derive"] }

View file

@ -311,8 +311,8 @@ async fn do_server_main(
}
};
let verify_spawner = Spawner::build("verify-cpu", verify_threads.try_into()?);
let sign_spawner = Spawner::build("sign-cpu", signature_threads.try_into()?);
let verify_spawner = Spawner::build("verify-cpu", verify_threads.try_into()?)?;
let sign_spawner = Spawner::build("sign-cpu", signature_threads.try_into()?)?;
let key_id = config.generate_url(UrlKind::MainKey).to_string();
let state = State::build(db.clone(), key_id, sign_spawner.clone(), client).await?;

View file

@ -8,14 +8,13 @@ pub(crate) struct Spawner {
}
impl Spawner {
pub(crate) fn build(name: &'static str, threads: u16) -> Self {
pub(crate) fn build(name: &'static str, threads: u16) -> anyhow::Result<Self> {
let pool = CpuPool::configure()
.name(name)
.max_threads(threads)
.build()
.expect("valid configuration");
.build()?;
Spawner { pool }
Ok(Spawner { pool })
}
pub(crate) async fn close(self) {