about summary refs log tree commit diff stats
path: root/src/server/shared_memory_server.h
diff options
context:
space:
mode:
authorChristian Krinitsin <mail@krinitsin.com>2025-03-21 22:13:38 +0100
committerChristian Krinitsin <mail@krinitsin.com>2025-03-21 22:13:38 +0100
commit7212db13b9013aa15673ae65da65eeaf97ee0d12 (patch)
tree9346b38f25ab5880af3f40e49ba1e64c4f7e0ca2 /src/server/shared_memory_server.h
parentb67a507e2ef0db4970f04df5c5a52d9b9e9dd74d (diff)
downloadBT-Programming-Assignment-7212db13b9013aa15673ae65da65eeaf97ee0d12.tar.gz
BT-Programming-Assignment-7212db13b9013aa15673ae65da65eeaf97ee0d12.zip
add doxygen-comments for each member
Diffstat (limited to 'src/server/shared_memory_server.h')
-rw-r--r--src/server/shared_memory_server.h30
1 files changed, 29 insertions, 1 deletions
diff --git a/src/server/shared_memory_server.h b/src/server/shared_memory_server.h
index aa0e261..4580d1a 100644
--- a/src/server/shared_memory_server.h
+++ b/src/server/shared_memory_server.h
@@ -8,9 +8,19 @@
 #include <sys/mman.h>
 #include <unistd.h>
 
+/**
+ * @class Server
+ * @brief Represents the server, which performs operations on the hashtable based on the requests of
+ * the client.
+ */
 template <typename K, typename V>
 class Server {
 public:
+    /**
+     * @brief Constructs a new hashtable and initializes a shared memory buffer.
+     *
+     * @param size The number of buckets in the hashtable.
+     */
     Server(size_t size)
         : hash_table(size)
     {
@@ -34,6 +44,9 @@ public:
         pthread_cond_init(&shared_memory->cond_var, &cond_attr);
     }
 
+    /**
+     * @brief Unmaps and unlinks the shared memory.
+     */
     ~Server()
     {
         munmap(shared_memory, sizeof(SharedMemory));
@@ -41,6 +54,11 @@ public:
         shm_unlink(SHM_NAME);
     }
 
+    /**
+     * @brief The main loop of the server.
+     *
+     * @details The server checks the shared memory for new requests and executes them.
+     */
     void process_requests()
     {
         while (true) {
@@ -121,8 +139,18 @@ public:
     }
 
 private:
+    /**
+     * @brief The hashtable.
+     */
     HashTable<K, V> hash_table;
 
-    int shm_fd;
+    /**
+     * @brief Memory which is shared with the client.
+     */
     SharedMemory* shared_memory;
+
+    /**
+     * @brief File descriptor for the shared memory, used to unmap and close the memory at the end.
+     */
+    int shm_fd;
 };