about summary refs log tree commit diff stats
path: root/src/common
diff options
context:
space:
mode:
Diffstat (limited to 'src/common')
-rw-r--r--src/common/shared_memory.h19
1 files changed, 19 insertions, 0 deletions
diff --git a/src/common/shared_memory.h b/src/common/shared_memory.h
index 70554e4..fe101ea 100644
--- a/src/common/shared_memory.h
+++ b/src/common/shared_memory.h
@@ -9,8 +9,14 @@
 #define MAX_KEY_SIZE 64
 #define MAX_VALUE_SIZE 128
 
+/**
+ * @brief Possible operations on the hashtable.
+ */
 enum Operations { INSERT, DELETE, GET, PRINT };
 
+/**
+ * @brief One request constists out of the operation, the arguments and the response.
+ */
 struct Request {
     Operations type;
     char key[MAX_KEY_SIZE];
@@ -18,6 +24,13 @@ struct Request {
     char response[MAX_VALUE_SIZE];
 };
 
+/**
+ * @brief The shared memory between client and server.
+ *
+ * @details The shared memory consists out of:
+ * - A circular-buffer, to de- and enqueue multiple request at once.
+ * - A mutex with a conditional variable, to ensure concurrency of the buffer.
+ */
 struct SharedMemory {
     Request request[QUEUE_SIZE];
     pthread_mutex_t mutex;
@@ -28,6 +41,9 @@ struct SharedMemory {
     bool full;
 };
 
+/**
+ * @brief Converts a generic type to a stringstream, so that it can be saved in the shared memory.
+ */
 template <typename T>
 std::string serialize(const T& data)
 {
@@ -36,6 +52,9 @@ std::string serialize(const T& data)
     return oss.str();
 }
 
+/**
+ * @brief Converts a stringstream to a generic type, so that value in the shared memory can be read.
+ */
 template <typename T>
 T deserialize(const std::string& str)
 {