From 57761f360992347a22681c80580d42261f0846a6 Mon Sep 17 00:00:00 2001 From: asonix Date: Thu, 21 May 2020 22:01:20 -0500 Subject: [PATCH] Use a better mutex --- Cargo.toml | 6 +++--- jobs-actix/Cargo.toml | 5 +++-- jobs-actix/src/server.rs | 2 +- jobs-core/Cargo.toml | 7 +++++-- jobs-core/src/storage.rs | 2 +- 5 files changed, 13 insertions(+), 9 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index c269e9e..573706c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "background-jobs" description = "Background Jobs implemented with actix and futures" -version = "0.8.0-alpha.2" +version = "0.8.0-alpha.3" license-file = "LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" @@ -21,10 +21,10 @@ members = [ default = ["background-jobs-actix"] [dependencies.background-jobs-core] -version = "0.8.0-alpha.0" +version = "0.8.0-alpha.3" path = "jobs-core" [dependencies.background-jobs-actix] -version = "0.8.0-alpha.1" +version = "0.8.0-alpha.3" path = "jobs-actix" optional = true diff --git a/jobs-actix/Cargo.toml b/jobs-actix/Cargo.toml index a80595b..f1aef37 100644 --- a/jobs-actix/Cargo.toml +++ b/jobs-actix/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "background-jobs-actix" description = "in-process jobs processor based on Actix" -version = "0.8.0-alpha.2" +version = "0.8.0-alpha.3" license-file = "../LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" @@ -12,8 +12,9 @@ edition = "2018" [dependencies] actix-rt = "1.1.0" anyhow = "1.0" +async-mutex = "1.0.1" async-trait = "0.1.24" -background-jobs-core = { version = "0.8.0-alpha.0", path = "../jobs-core", features = ["with-actix"] } +background-jobs-core = { version = "0.8.0-alpha.3", path = "../jobs-core", features = ["with-actix"] } chrono = "0.4" log = "0.4" num_cpus = "1.10.0" diff --git a/jobs-actix/src/server.rs b/jobs-actix/src/server.rs index 31f53de..0a150df 100644 --- a/jobs-actix/src/server.rs +++ b/jobs-actix/src/server.rs @@ -7,6 +7,7 @@ use actix_rt::{ time::{interval_at, Instant}, }; use anyhow::Error; +use async_mutex::Mutex; use background_jobs_core::{NewJobInfo, ReturnJobInfo, Stats, Storage}; use log::{error, trace}; use std::{ @@ -14,7 +15,6 @@ use std::{ sync::Arc, time::Duration, }; -use tokio::sync::Mutex; type WorkerQueue = VecDeque>; diff --git a/jobs-core/Cargo.toml b/jobs-core/Cargo.toml index 1b5c2a3..e45a6c5 100644 --- a/jobs-core/Cargo.toml +++ b/jobs-core/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "background-jobs-core" description = "Core types for implementing an asynchronous jobs processor" -version = "0.8.0-alpha.2" +version = "0.8.0-alpha.3" license-file = "../LICENSE" authors = ["asonix "] repository = "https://git.asonix.dog/Aardwolf/background-jobs" @@ -16,12 +16,15 @@ with-actix = ["actix-rt", "tokio"] [dependencies] actix-rt = { version = "1.1.0", optional = true } anyhow = "1.0" +async-mutex = "1.0.1" async-trait = "0.1.24" chrono = { version = "0.4", features = ["serde"] } -futures = "0.3.4" log = "0.4" serde = { version = "1.0", features = ["derive"] } serde_json = "1.0" thiserror = "1.0" tokio = { version = "0.2.13", optional = true } uuid = { version = "0.8.1", features = ["serde", "v4"] } + +[dev-dependencies] +futures = "0.3.4" diff --git a/jobs-core/src/storage.rs b/jobs-core/src/storage.rs index 2c3f557..6697faa 100644 --- a/jobs-core/src/storage.rs +++ b/jobs-core/src/storage.rs @@ -135,8 +135,8 @@ pub trait Storage: Clone + Send { /// A default, in-memory implementation of a storage mechanism pub mod memory_storage { use super::{JobInfo, Stats}; + use async_mutex::Mutex; use chrono::Utc; - use futures::lock::Mutex; use std::{collections::HashMap, convert::Infallible, sync::Arc}; use uuid::Uuid;