diff options
| author | Christian Krinitsin <mail@krinitsin.com> | 2025-03-21 22:13:38 +0100 |
|---|---|---|
| committer | Christian Krinitsin <mail@krinitsin.com> | 2025-03-21 22:13:38 +0100 |
| commit | 7212db13b9013aa15673ae65da65eeaf97ee0d12 (patch) | |
| tree | 9346b38f25ab5880af3f40e49ba1e64c4f7e0ca2 /src/common | |
| parent | b67a507e2ef0db4970f04df5c5a52d9b9e9dd74d (diff) | |
| download | BT-Programming-Assignment-7212db13b9013aa15673ae65da65eeaf97ee0d12.tar.gz BT-Programming-Assignment-7212db13b9013aa15673ae65da65eeaf97ee0d12.zip | |
add doxygen-comments for each member
Diffstat (limited to 'src/common')
| -rw-r--r-- | src/common/shared_memory.h | 19 |
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) { |