summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorlittleblack111 <littleblack11111@gmail.com>2025-05-31 15:56:53 +0800
committerlittleblack111 <littleblack11111@gmail.com>2025-05-31 15:57:27 +0800
commit404b6c7c74fd1eecb54b63e13073b4a093a475b0 (patch)
tree80b088e48ca38840846f58027e321b8acb8d7c94 /src
parentc230f53a36520e2249905220408b2740786de59d (diff)
style: remove unncessary Hyprutils::OS NS
Diffstat (limited to 'src')
-rw-r--r--src/FileDescriptor.cpp2
-rw-r--r--src/FileDescriptor.hpp4
-rw-r--r--src/server.cpp4
-rw-r--r--src/server.hpp8
-rw-r--r--src/session.cpp2
-rw-r--r--src/session.hpp2
6 files changed, 9 insertions, 13 deletions
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 <unistd.h>
#include <utility>
-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 <fcntl.h>
-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 <sys/socket.h>
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<CServer> 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 <sys/socket.h>
CSession::CSession() {
- m_sockfd = Hyprutils::OS::CFileDescriptor{accept(g_pServer->getSocket()->get(), reinterpret_cast<sockaddr *>(&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<sockaddr *>(&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<std::jthread, std::shared_ptr<CSession>> *self;
- Hyprutils::OS::CFileDescriptor m_sockfd;
+ CFileDescriptor m_sockfd;
sockaddr_in m_addr;
socklen_t m_addrLen = sizeof(m_addr);
std::string m_name;