cloud-fan commented on a change in pull request #34245:
URL: https://github.com/apache/spark/pull/34245#discussion_r728113602



##########
File path: core/src/main/scala/org/apache/spark/TaskContextImpl.scala
##########
@@ -82,23 +82,33 @@ private[spark] class TaskContextImpl(
   @volatile private var _fetchFailedException: Option[FetchFailedException] = 
None
 
   @GuardedBy("this")
-  override def addTaskCompletionListener(listener: TaskCompletionListener)
-      : this.type = synchronized {
-    if (completed) {
+  override def addTaskCompletionListener(listener: TaskCompletionListener): 
this.type = {
+    val needToCallListener = synchronized {
+      if (completed) {
+        true
+      } else {
+        onCompleteCallbacks += listener
+        false
+      }
+    }

Review comment:
       > There are no ordering guarantees for listeners registered in different 
threads
   
   I agree. When there are multiple threads I don't think we can define an 
"order".




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



---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to