ExtensionManagerRunner::~ExtensionManagerRunner() { // Only attempt to remove stale paths if the server was started. std::unique_lock<std::mutex> lock(service_start_); if (server_ != nullptr) { removeStalePaths(path_); } }
ExtensionManagerRunner::~ExtensionManagerRunner() { // Only attempt to remove stale paths if the server was started. boost::lock_guard<boost::mutex> lock(service_start_); if (server_ != nullptr) { removeStalePaths(path_); } }
void ExtensionRunnerCore::startServer(TProcessorRef processor) { { boost::lock_guard<boost::mutex> lock(service_start_); // A request to stop the service may occur before the thread starts. if (service_stopping_) { return; } transport_ = TServerTransportRef(new TServerSocket(path_)); // Before starting and after stopping the manager, remove stale sockets. removeStalePaths(path_); // Construct the service's transport, protocol, thread pool. auto transport_fac = TTransportFactoryRef(new TBufferedTransportFactory()); auto protocol_fac = TProtocolFactoryRef(new TBinaryProtocolFactory()); // Start the Thrift server's run loop. server_ = TThreadedServerRef(new TThreadedServer( processor, transport_, transport_fac, protocol_fac)); } { boost::lock_guard<boost::mutex> lock(service_run_); server_->serve(); } }
ExtensionManagerRunner::~ExtensionManagerRunner() { if (server_ != nullptr) { // Eventually this extension manager should be stopped. // This involves a lock around assuring the thread context for destruction // matches and the server has begun serving (potentially opaque to our // our use of ThreadPollServer API). // In newer (forks) version of thrift this server implementation has been // deprecated. // server_->stop(); removeStalePaths(path_); } }
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(); }
ExtensionManagerRunner::~ExtensionManagerRunner() { if (server_ != nullptr) { removeStalePaths(path_); } }