From 7212db13b9013aa15673ae65da65eeaf97ee0d12 Mon Sep 17 00:00:00 2001 From: Christian Krinitsin Date: Fri, 21 Mar 2025 22:13:38 +0100 Subject: add doxygen-comments for each member --- src/common/shared_memory.h | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) (limited to 'src/common/shared_memory.h') 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 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 T deserialize(const std::string& str) { -- cgit 1.4.1