gaoyunhaii commented on a change in pull request #13357:
URL: https://github.com/apache/flink/pull/13357#discussion_r492529818



##########
File path: 
flink-runtime/src/main/java/org/apache/flink/runtime/operators/sort/CircularQueues.java
##########
@@ -0,0 +1,98 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+package org.apache.flink.runtime.operators.sort;
+
+import org.apache.flink.util.FlinkRuntimeException;
+import org.apache.flink.util.MutableObjectIterator;
+
+import java.util.concurrent.BlockingQueue;
+import java.util.concurrent.CompletableFuture;
+import java.util.concurrent.LinkedBlockingQueue;
+import java.util.concurrent.TimeUnit;
+
+/**
+ * Collection of queues that are used for the communication between the 
threads.
+ */
+final class CircularQueues<E> implements StageRunner.StageMessageDispatcher<E> 
{
+       private final BlockingQueue<CircularElement<E>> empty;
+       private final BlockingQueue<CircularElement<E>> sort;
+       private final BlockingQueue<CircularElement<E>> spill;
+
+       private boolean isFinished = false;

Review comment:
       Very sorry that there is one issue missing, but it just come to me that 
we might need to make the `isFinished` to be `volatile`: the 
`CircularQueues#close()` might be called from `SpilledThread` or `SortThread`, 
and we might need to read this variable in the task main thread. Since 
`ExternalSorter#close()` guarantees that there should be no concurrent writer, 
therefore where we need only `volatile` instead of atomic variables here.




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