Ejemplo n.º 1
0
void TNonblockingIOThread::run() {
  if (eventBase_ == NULL)
    registerEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...", number_);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(true);
  }

  // Run libevent engine, never returns, invokes calls to eventHandler
  event_base_loop(eventBase_, 0);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(false);
  }

  // cleans up our registered events
  cleanupEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d run() done!", number_);
}
void TNonblockingIOThread::run() {
  threadId_ = Thread::get_current();

  assert(eventBase_ == 0);
  eventBase_ = event_base_new();

  // Print some libevent stats
  if (number_ == 0) {
    GlobalOutput.printf("TNonblockingServer: using libevent %s method %s",
            event_get_version(),
            event_base_get_method(eventBase_));
  }


  registerEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d entering loop...",
                      number_);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(true);
  }

  // Run libevent engine, never returns, invokes calls to eventHandler
  event_base_loop(eventBase_, 0);

  if (useHighPriority_) {
    setCurrentThreadHighPriority(false);
  }

  // cleans up our registered events
  cleanupEvents();

  GlobalOutput.printf("TNonblockingServer: IO thread #%d run() done!",
    number_);
}