From 404b6c7c74fd1eecb54b63e13073b4a093a475b0 Mon Sep 17 00:00:00 2001 From: littleblack111 Date: Sat, 31 May 2025 15:56:53 +0800 Subject: style: remove unncessary Hyprutils::OS NS --- src/FileDescriptor.cpp | 2 -- src/FileDescriptor.hpp | 4 ---- src/server.cpp | 4 ++-- src/server.hpp | 8 +++++--- src/session.cpp | 2 +- src/session.hpp | 2 +- 6 files changed, 9 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/FileDescriptor.cpp b/src/FileDescriptor.cpp index 79ccce2..92505f5 100644 --- a/src/FileDescriptor.cpp +++ b/src/FileDescriptor.cpp @@ -5,8 +5,6 @@ #include #include -using namespace Hyprutils::OS; - CFileDescriptor::CFileDescriptor(int const fd) : m_fd(fd) {} diff --git a/src/FileDescriptor.hpp b/src/FileDescriptor.hpp index 3ba31c2..75aeb73 100644 --- a/src/FileDescriptor.hpp +++ b/src/FileDescriptor.hpp @@ -1,8 +1,6 @@ #pragma once #include -namespace Hyprutils { -namespace OS { class CFileDescriptor { public: CFileDescriptor() = default; @@ -35,5 +33,3 @@ class CFileDescriptor { private: int m_fd = -1; }; -}; // namespace OS -}; // namespace Hyprutils diff --git a/src/server.cpp b/src/server.cpp index 5f79120..9b5dae0 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -4,7 +4,7 @@ #include CServer::CServer(uint16_t port) - : m_sockfd(Hyprutils::OS::CFileDescriptor{socket(AF_INET, SOCK_STREAM, 0)}) { + : m_sockfd(CFileDescriptor{socket(AF_INET, SOCK_STREAM, 0)}) { if (!m_sockfd.isValid()) throw std::runtime_error("Failed to create socket"); @@ -33,6 +33,6 @@ CServer::~CServer() { log(SYS, "Server: bye"); } -const Hyprutils::OS::CFileDescriptor *CServer::getSocket() const { +const CFileDescriptor *CServer::getSocket() const { return &m_sockfd; } diff --git a/src/server.hpp b/src/server.hpp index 7fa5543..5d12c97 100644 --- a/src/server.hpp +++ b/src/server.hpp @@ -8,10 +8,12 @@ class CServer { public: CServer(uint16_t port); ~CServer(); - const Hyprutils::OS::CFileDescriptor *getSocket() const; + const CFileDescriptor *getSocket() const; private: - Hyprutils::OS::CFileDescriptor m_sockfd; - sockaddr_in m_addr; + CFileDescriptor m_sockfd; + sockaddr_in m_addr; + + mutable std::mutex m_mutex; }; inline std::unique_ptr g_pServer; diff --git a/src/session.cpp b/src/session.cpp index c12ea0b..1259dbe 100644 --- a/src/session.cpp +++ b/src/session.cpp @@ -12,7 +12,7 @@ #include CSession::CSession() { - m_sockfd = Hyprutils::OS::CFileDescriptor{accept(g_pServer->getSocket()->get(), reinterpret_cast(&m_addr), &m_addrLen)}; // if this is in the init list, it will run before m_addrLen, so it won't work :/ + m_sockfd = CFileDescriptor{accept(g_pServer->getSocket()->get(), reinterpret_cast(&m_addr), &m_addrLen)}; // if this is in the init list, it will run before m_addrLen, so it won't work :/ if (!m_sockfd.isValid()) throw std::runtime_error("session: Failed to create socket"); diff --git a/src/session.hpp b/src/session.hpp index 263dcb6..2558774 100644 --- a/src/session.hpp +++ b/src/session.hpp @@ -57,7 +57,7 @@ class CSession { }; std::pair> *self; - Hyprutils::OS::CFileDescriptor m_sockfd; + CFileDescriptor m_sockfd; sockaddr_in m_addr; socklen_t m_addrLen = sizeof(m_addr); std::string m_name; -- cgit v1.2.3