예제 #1
0
파일: reactor.cpp 프로젝트: wuurrd/twistec
void Reactor::handle_signal(int signal)
{
	std::clog
		<< "Signal "
		<< signal
		<< "caught. Terminating mainloop"
		<< std::endl;
    Reactor* reactor = getInstance();
    reactor->stop();
}
예제 #2
0
파일: acceptor.cpp 프로젝트: roitk/freeflow
// 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;
}
예제 #3
0
void print_hello_world(){
	std::cout << "Hello World" << std::endl;
	Reactor *reactor = Reactor::getInstance();
	reactor->stop();
}