junrao commented on code in PR #14629:
URL: https://github.com/apache/kafka/pull/14629#discussion_r1382212898


##########
core/src/main/scala/kafka/server/KafkaRequestHandler.scala:
##########
@@ -50,28 +50,32 @@ object KafkaRequestHandler {
   }
 
   /**
-   * Wrap callback to schedule it on a request thread.
-   * NOTE: this function must be called on a request thread.
-   * @param fun Callback function to execute
-   * @return Wrapped callback that would execute `fun` on a request thread
+   * Execute or create a callback to be asynchronously scheduled on an 
arbitrary request thread
+   * NOTE: this function must be originally called from a request thread.
+   * @param asyncCompletionCallback A callback method that is expected to be 
executed once in an arbitrary request
+   *                                handler thread after an asynchronous 
action completes. The RequestLocal passed in
+   *                                must belong to the request handler thread 
that is executing the callback.
+   * @param requestLocal The RequestLocal for the current request handler 
thread in case we need to execute the callback
+   *                     function immediately without queueing the callback 
request
+   * @return Wrapped callback that schedules `asyncCompletionCallback` on an 
arbitrary request thread
    */
-  def wrap[T](fun: T => Unit): T => Unit = {
+  def executeOrRegisterAsyncCallback[T](asyncCompletionCallback: 
(RequestLocal, T) => Unit, requestLocal: RequestLocal): T => Unit = {

Review Comment:
   Sorry, just realized that this method doesn't execute or register the 
callback directly. It creates a wrapped callback for that instead. So, `wrap` 
is still the more appropriate name. We could probably change the description to 
sth like "Creates a wrapped callback to be executed synchronously on the 
calling request thread or asynchronously on an arbitrary request thread."



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