void Reactor::handle_signal(int signal) { std::clog << "Signal " << signal << "caught. Terminating mainloop" << std::endl; Reactor* reactor = getInstance(); reactor->stop(); }
// When data is available for reading, accept the connection // and spawn a new handler. bool Acceptor::on_read(Reactor& r) { // FIXME: The error handling stuff is not good. Connection* c; try { c = new Connection(rc().accept()); } catch(System_error&) { perror("error"); r.stop(); return false; } catch(std::runtime_error& err) { std::cout << err.what() << '\n'; r.stop(); return false; } // Register the connection. r.add_handler(c); return true; }
void print_hello_world(){ std::cout << "Hello World" << std::endl; Reactor *reactor = Reactor::getInstance(); reactor->stop(); }