BewareMyPower edited a comment on pull request #8519:
URL: https://github.com/apache/pulsar/pull/8519#issuecomment-725214827


   By the way, there's another solution that checks `error_code` for 
`boost::asio::error::operation_aborted`:
   
   ```diff
   diff --git a/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc 
b/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc
   index 5c61ccaf164..a5ce0172fb8 100644
   --- a/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc
   +++ b/pulsar-client-cpp/lib/AckGroupingTrackerEnabled.cc
   @@ -144,7 +144,7 @@ void AckGroupingTrackerEnabled::scheduleTimer() {
        this->timer_ = this->executor_->createDeadlineTimer();
        
this->timer_->expires_from_now(boost::posix_time::milliseconds(std::max(1L, 
this->ackGroupingTimeMs_)));
        this->timer_->async_wait([this](const boost::system::error_code& ec) -> 
void {
   -        if (!ec) {
   +        if (!ec && ec != boost::system::error::operation_aborted) {
                this->flush();
                this->scheduleTimer();
            }
   ```
   
   PROS: The `unique_ptr` is more efficient because it avoids the overhead of 
reference count's atomic operation
   CONS: If the timer was cancelled, the pending messages may not be 
acknowledged. Though the destructor calls `flush` so that maybe we can treat it 
as already flushed.


----------------------------------------------------------------
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.

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


Reply via email to