BewareMyPower commented on a change in pull request #12586:
URL: https://github.com/apache/pulsar/pull/12586#discussion_r741628188



##########
File path: pulsar-client-cpp/lib/Future.h
##########
@@ -99,21 +100,24 @@ class Promise {
         }
 
         state->value = value;
-        state->result = Result();
+        state->result = DEFAULT_RESULT;
         state->complete = true;
 
-        typename std::list<ListenerCallback>::iterator it;
-        for (it = state->listeners.begin(); it != state->listeners.end(); 
++it) {
-            ListenerCallback& callback = *it;
-            callback(state->result, state->value);
+        const auto listeners = std::move(state->listeners);
+
+        lock.unlock();
+
+        for (auto& callback : listeners) {
+            callback(DEFAULT_RESULT, value);
         }
 
         state->listeners.clear();

Review comment:
       Sounds reasonable. Ideally we should not use the object that has been 
moved. I'll adopt the swap way.




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


Reply via email to