Skip to content

Commit

Permalink
DBusManager: Remove unnecessary locks from getters in singleton
Browse files Browse the repository at this point in the history
  • Loading branch information
Iamanaws committed Jan 4, 2025
1 parent 00b02c0 commit b22009f
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 8 deletions.
5 changes: 0 additions & 5 deletions src/core/DBusManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,28 +33,24 @@ void DBusManager::initializeConnection() {
}

std::shared_ptr<sdbus::IConnection> DBusManager::getConnection() {
std::lock_guard<std::mutex> lock(m_mutex);
return m_pConnection;
}

std::shared_ptr<sdbus::IProxy> DBusManager::getLoginProxy() {
std::lock_guard<std::mutex> lock(m_mutex);
if (!m_pLoginProxy)
initializeConnection();

return m_pLoginProxy;
}

std::shared_ptr<sdbus::IProxy> DBusManager::getSessionProxy() {
std::lock_guard<std::mutex> lock(m_mutex);
if (!m_pSessionProxy)
initializeConnection();

return m_pSessionProxy;
}

void DBusManager::setLockedHint(bool locked) {
std::lock_guard<std::mutex> lock(m_mutex);
if (!m_pSessionProxy) {
Debug::log(WARN, "[DBusManager] Cannot set locked hint: Proxy is not initialized.");
return;
Expand All @@ -71,7 +67,6 @@ void DBusManager::setLockedHint(bool locked) {
}

void DBusManager::sendUnlockSignal() {
std::lock_guard<std::mutex> lock(m_mutex);
if (!m_pSessionProxy) {
Debug::log(WARN, "[DBusManager] Unlock signal skipped: Proxy is not initialized.");
return;
Expand Down
3 changes: 0 additions & 3 deletions src/core/DBusManager.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

#include <memory>
#include <string>
#include <mutex>
#include <sdbus-c++/sdbus-c++.h>

class DBusManager {
Expand All @@ -25,6 +24,4 @@ class DBusManager {
std::shared_ptr<sdbus::IConnection> m_pConnection;
std::shared_ptr<sdbus::IProxy> m_pLoginProxy;
std::shared_ptr<sdbus::IProxy> m_pSessionProxy;

std::mutex m_mutex;
};

0 comments on commit b22009f

Please sign in to comment.