From 84c32953ae5f52be44af4b48381747f55cb04f4a Mon Sep 17 00:00:00 2001 From: FxQnLr Date: Sun, 29 Oct 2023 20:30:01 +0100 Subject: impl dashmap --- src/main.rs | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'src/main.rs') diff --git a/src/main.rs b/src/main.rs index 545d8fe..762a817 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,12 +1,11 @@ -use std::collections::HashMap; use std::env; use std::sync::Arc; use axum::{Router, routing::post}; use axum::routing::{get, put}; +use dashmap::DashMap; use sqlx::PgPool; use time::util::local_offset; use tokio::sync::broadcast::{channel, Sender}; -use tokio::sync::Mutex; use tracing::{info, level_filters::LevelFilter}; use tracing_subscriber::{EnvFilter, fmt::{self, time::LocalTime}, prelude::*}; use crate::config::SETTINGS; @@ -51,9 +50,9 @@ async fn main() { let (tx, _) = channel(32); - let ping_map: HashMap = HashMap::new(); + let ping_map: DashMap = DashMap::new(); - let shared_state = Arc::new(AppState { db, ping_send: tx, ping_map: Arc::new(Mutex::new(ping_map)) }); + let shared_state = Arc::new(AppState { db, ping_send: tx, ping_map: Arc::new(ping_map) }); let app = Router::new() .route("/start", post(start)) -- cgit v1.2.3