-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
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
1 parent
dc605cf
commit 6fe4be0
Showing
1 changed file
with
8 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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> { | ||
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()); | ||
} | ||
} |