You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2021/10/20 15:43:32 UTC
[GitHub] [pulsar] merlimat commented on a change in pull request #12427: Fix frequent segmentation fault of Python tests by refactoring ExecutorService
merlimat commented on a change in pull request #12427:
URL: https://github.com/apache/pulsar/pull/12427#discussion_r732913138
##########
File path: pulsar-client-cpp/lib/ExecutorService.cc
##########
@@ -27,22 +27,30 @@ DECLARE_LOG_OBJECT()
namespace pulsar {
-ExecutorService::ExecutorService()
- : io_service_(new boost::asio::io_service()),
- work_(new BackgroundWork(*io_service_)),
- worker_(std::bind(&ExecutorService::startWorker, this, io_service_)) {}
+ExecutorService::ExecutorService() {}
ExecutorService::~ExecutorService() { close(); }
-void ExecutorService::startWorker(std::shared_ptr<boost::asio::io_service> io_service) { io_service_->run(); }
+void ExecutorService::start() {
+ auto self = shared_from_this();
+ std::thread t{[self] {
+ if (self->isClosed()) {
+ return;
+ }
+ boost::system::error_code ec;
+ self->getIOService().run(ec);
Review comment:
When we stop the IOService, will the `run()` terminate even if the `work_` item is still there?
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: commits-unsubscribe@pulsar.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org