blob: 42b7668d6711b4e09bd94680e0c4ea2c7f6d9dbd (
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
40
41
42
43
44
45
46
|
#include <csignal>
#include <cstdint>
#include <iostream>
#include <stdexcept>
#include <string>
#include "server.h"
Server<int, int> shm;
/**
* @brief Shuts the server down, when pressing <Ctrl+C>.
*
* @param signal Specifies the signal, which was caught.
*/
void signal_handler(int signal)
{
if (signal == SIGINT) {
std::cout << "Server shutting down" << '\n';
exit(0);
}
}
int main(int argc, char* argv[])
{
if (argc != 2) {
std::cout << "Usage: " << argv[0] << " <number-of-buckets>\n";
return 1;
}
uint32_t size;
try {
size = std::stoi(std::string(argv[1]));
} catch (const std::invalid_argument& e) {
std::cout << "Invalid argument" << '\n';
return 1;
}
shm.initialize_hashtable(size);
std::signal(SIGINT, signal_handler);
shm.process_requests();
return 0;
}
|