Dispatcher::Dispatcher() { thread_manager_ = InternalThreadManager::newSimpleThreadManager( (size_t)FLAGS_worker_threads, 0); auto thread_factory = ThriftThreadFactory(new PosixThreadFactory()); thread_manager_->threadFactory(thread_factory); thread_manager_->start(); }
void ExtensionRunnerCore::startServer(TProcessorRef processor) { auto transport = TServerTransportRef(new TServerSocket(path_)); // Before starting and after stopping the manager, remove stale sockets. removeStalePaths(path_); auto transport_fac = TTransportFactoryRef(new TBufferedTransportFactory()); auto protocol_fac = TProtocolFactoryRef(new TBinaryProtocolFactory()); // The minimum number of worker threads is 1. size_t threads = (FLAGS_worker_threads > 0) ? FLAGS_worker_threads : 1; manager_ = ThreadManager::newSimpleThreadManager(threads, 0); auto thread_fac = ThriftThreadFactory(new PosixThreadFactory()); manager_->threadFactory(thread_fac); manager_->start(); // Start the Thrift server's run loop. server_ = TThreadPoolServerRef(new TThreadPoolServer( processor, transport, transport_fac, protocol_fac, manager_)); server_->serve(); }