July 2017
Intermediate to advanced
244 pages
6h 33m
English
As is usual, we start off with the main function, contained in main.cpp:
#include "dispatcher.h"#include "request.h"#include <iostream>#include <string>#include <csignal>#include <thread>#include <chrono>using namespace std;sig_atomic_t signal_caught = 0;mutex logMutex;
The custom headers we include are those for our dispatcher implementation, as well as the request class that we'll use.
Globally, we define an atomic variable to be used with the signal handler, as well as a mutex which will synchronize the output (on the standard output) from our logging method:
void sigint_handler(int sig) { signal_caught = 1;}
Our signal handler function (for SIGINT signals) simply sets the global atomic variable that we defined earlier: ...
Read now
Unlock full access