提交 3fe6ed7b 编写于 作者: J Jesse Glick

Make sure rebuildDependencyGraphAsync does not repeat work if called many...

Make sure rebuildDependencyGraphAsync does not repeat work if called many times in quick succession.
上级 28e403ac
......@@ -289,6 +289,7 @@ import java.util.concurrent.LinkedBlockingQueue;
import java.util.concurrent.ThreadPoolExecutor;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import java.util.logging.Level;
import static java.util.logging.Level.SEVERE;
import java.util.logging.LogRecord;
......@@ -434,6 +435,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
private List<JDK> jdks = new ArrayList<JDK>();
private transient volatile DependencyGraph dependencyGraph;
private final transient AtomicBoolean dependencyGraphDirty = new AtomicBoolean();
/**
* Currently active Views tab bar.
......@@ -3609,6 +3611,7 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
// volatile acts a as a memory barrier here and therefore guarantees
// that graph is fully build, before it's visible to other threads
dependencyGraph = graph;
dependencyGraphDirty.set(false);
}
/**
......@@ -3621,10 +3624,13 @@ public class Jenkins extends AbstractCIBase implements ModifiableTopLevelItemGro
* @since 1.522
*/
public Future<DependencyGraph> rebuildDependencyGraphAsync() {
return MasterComputer.threadPoolForRemoting.submit(new java.util.concurrent.Callable<DependencyGraph>() {
dependencyGraphDirty.set(true);
return Timer.get().submit(new java.util.concurrent.Callable<DependencyGraph>() {
@Override
public DependencyGraph call() throws Exception {
rebuildDependencyGraph();
if (dependencyGraphDirty.get()) {
rebuildDependencyGraph();
}
return dependencyGraph;
}
});
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册