blob: 43fe2f5c425d5df1fd0522f6c50a99d0cf0b7bf8 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
#pragma once
#include <pthread.h>
#include <sstream>
#define SHM_NAME "/hashtable_queue"
#define MAX_KEY_SIZE 64
#define MAX_VALUE_SIZE 128
enum Operations { INSERT, DELETE, GET, PRINT };
struct Request {
Operations type;
char key[MAX_KEY_SIZE];
char value[MAX_VALUE_SIZE];
};
struct SharedMemory {
Request request;
bool processed;
char response[MAX_VALUE_SIZE];
};
template <typename T>
std::string serialize(const T& data)
{
std::ostringstream oss;
oss << data;
return oss.str();
}
template <typename T>
T deserialize(const std::string& str)
{
std::istringstream iss(str);
T data;
iss >> data;
return data;
}
|