rdhabalia commented on a change in pull request #9900:
URL: https://github.com/apache/pulsar/pull/9900#discussion_r594889641



##########
File path: 
pulsar-metadata/src/main/java/org/apache/pulsar/metadata/api/MetadataCache.java
##########
@@ -103,6 +103,18 @@
      */
     CompletableFuture<Void> readModifyUpdate(String path, Function<T, T> 
modifyFunction);
 
+    /**
+     * Perform an atomic read-modify-update of the value.
+     * <p>
+     * And the read value will be cloned to avoid directly modifying the 
reference.
+     * <p>
+     * The modify function can potentially be called multiple times if there 
are concurrent updates happening.
+     * @param path
+     * @param modifyFunction
+     * @return
+     */
+    CompletableFuture<Void> readCloneModifyUpdate(String path, Function<T, T> 
modifyFunction);

Review comment:
       Having separate behavior of thread-safe and non-thread-safe can confuse 
the caller. can we keep the default method with a thread-safety contract and 
let each implementation handle its own way. `cloneData` flag might not be 
relevant to all different implementations to achieve atomic behavior.




----------------------------------------------------------------
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:
[email protected]


Reply via email to