BewareMyPower commented on code in PR #54:
URL: https://github.com/apache/pulsar-client-cpp/pull/54#discussion_r1000388280
##########
lib/PartitionedProducerImpl.h:
##########
@@ -17,16 +17,16 @@
* under the License.
*/
#include "ProducerImpl.h"
-#include "ClientImpl.h"
#include <vector>
-
#include <mutex>
#include <pulsar/MessageRoutingPolicy.h>
#include <pulsar/TopicMetadata.h>
#include <lib/TopicName.h>
namespace pulsar {
+class ClientImpl;
+
class PartitionedProducerImpl : public ProducerImplBase,
Review Comment:
No. Because it doesn't implement `HandlerBase` and has no `connection_`
field. The `ClientConnection` instance doesn't hold any
`PartitionedProducerImpl` reference
##########
lib/ConsumerImpl.cc:
##########
@@ -1018,66 +1035,31 @@ void ConsumerImpl::closeAsync(ResultCallback callback) {
ClientConnectionPtr cnx = getCnx().lock();
if (!cnx) {
- state_ = Closed;
// If connection is gone, also the consumer is closed on the broker
side
- if (callback) {
- callback(ResultOk);
- }
+ callback(ResultOk);
return;
}
- ClientImplPtr client = client_.lock();
- if (!client) {
- state_ = Closed;
- // Client was already destroyed
- if (callback) {
- callback(ResultOk);
- }
- return;
- }
+ int requestId = client_.newRequestId();
- int requestId = client->newRequestId();
- Future<Result, ResponseData> future =
- cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_,
requestId), requestId);
- if (callback) {
- // Pass the shared pointer "ptr" to the handler to prevent the object
from being destroyed
- future.addListener(std::bind(&ConsumerImpl::handleClose,
get_shared_this_ptr(), std::placeholders::_1,
- callback, ptr));
- }
-
- // fail pendingReceive callback
- failPendingReceiveCallback();
- failPendingBatchReceiveCallback();
+ auto self = get_shared_this_ptr();
+ cnx->sendRequestWithId(Commands::newCloseConsumer(consumerId_, requestId),
requestId)
+ .addListener([this, self, callback](Result result, const
ResponseData&) { callback(result); });
Review Comment:
Yes
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]