Skip to content

Commit

Permalink
Updates ServiceManager
Browse files Browse the repository at this point in the history
Removed RwLock wrapper from sessions
Removed async from all the methods

See: #73 (comment)

Signed-off-by: Dhanuka Warusadura <dhanuka@gnome.org>
  • Loading branch information
warusadura committed Feb 21, 2024
1 parent dd9a71a commit 92bac7a
Showing 1 changed file with 8 additions and 14 deletions.
22 changes: 8 additions & 14 deletions server/src/daemon/service_manager.rs
Original file line number Diff line number Diff line change
@@ -1,36 +1,30 @@
use std::collections::HashMap;

use tokio::sync::RwLock;
use zbus::zvariant::{ObjectPath, OwnedObjectPath};

use super::session::Session;

#[derive(Debug)]
pub struct ServiceManager {
sessions: RwLock<HashMap<OwnedObjectPath, Session>>,
sessions: HashMap<OwnedObjectPath, Session>,
}

impl ServiceManager {
pub fn new() -> Self {
Self {
sessions: RwLock::new(HashMap::new()),
sessions: HashMap::new(),
}
}

pub async fn session(&self, path: ObjectPath<'_>) -> Option<Session> {
self.sessions
.read()
.await
.get(&path.into())
.to_owned()
.cloned()
pub fn session(&self, path: ObjectPath<'_>) -> Option<Session> {

Check failure on line 19 in server/src/daemon/service_manager.rs

View workflow job for this annotation

GitHub Actions / Clippy

methods `session` and `remove_session` are never used

Check warning on line 19 in server/src/daemon/service_manager.rs

View workflow job for this annotation

GitHub Actions / Check

methods `session` and `remove_session` are never used
self.sessions.get(&path.into()).to_owned().cloned()
}

pub async fn insert_session(&mut self, path: ObjectPath<'_>, session: Session) {
self.sessions.write().await.insert(path.into(), session);
pub fn insert_session(&mut self, path: ObjectPath<'_>, session: Session) {
self.sessions.insert(path.into(), session);
}

pub async fn remove_session(&mut self, path: ObjectPath<'_>) {
self.sessions.write().await.remove(&path.into());
pub fn remove_session(&mut self, path: ObjectPath<'_>) {
self.sessions.remove(&path.into());
}
}

0 comments on commit 92bac7a

Please sign in to comment.