do not hardcode to BoundedTaskExecutor private implementation details

This commit is contained in:
Alexey Kudravtsev
2015-10-07 13:14:35 +03:00
parent 95623cf89c
commit ee9afc87e5
@@ -1,5 +1,5 @@
/*
* Copyright 2000-2014 JetBrains s.r.o.
* Copyright 2000-2015 JetBrains s.r.o.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -22,6 +22,7 @@ import com.intellij.openapi.util.io.BufferExposingByteArrayOutputStream;
import com.intellij.openapi.util.io.FileSystemUtil;
import com.intellij.openapi.util.io.FileUtil;
import com.intellij.openapi.util.text.StringUtil;
import com.intellij.util.concurrency.Semaphore;
import com.intellij.util.concurrency.SequentialTaskExecutor;
import com.intellij.util.io.DataOutputStream;
import io.netty.channel.Channel;
@@ -49,7 +50,6 @@ import java.util.concurrent.ExecutionException;
import java.util.concurrent.Future;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import java.util.concurrent.atomic.AtomicBoolean;
import static org.jetbrains.jps.api.CmdlineRemoteProto.Message.ControllerMessage.ParametersMessage.TargetTypeBuildScope;
@@ -64,7 +64,7 @@ final class BuildSession implements Runnable, CanceledStatus {
private final Channel myChannel;
@Nullable
private final PreloadedData myPreloadedData;
private volatile boolean myCanceled = false;
private volatile boolean myCanceled;
private final String myProjectPath;
@Nullable
private CmdlineRemoteProto.Message.ControllerMessage.FSEvent myInitialFSDelta;
@@ -345,7 +345,7 @@ final class BuildSession implements Runnable, CanceledStatus {
}
public void processFSEvent(final CmdlineRemoteProto.Message.ControllerMessage.FSEvent event) {
myEventsProcessor.submit(new Runnable() {
myEventsProcessor.execute(new Runnable() {
@Override
public void run() {
try {
@@ -646,23 +646,21 @@ final class BuildSession implements Runnable, CanceledStatus {
}
private static class EventsProcessor extends SequentialTaskExecutor {
private final AtomicBoolean myProcessingEnabled = new AtomicBoolean(false);
private final Semaphore myProcessingEnabled = new Semaphore();
EventsProcessor() {
private EventsProcessor() {
super(SharedThreadPool.getInstance());
myProcessingEnabled.down();
execute(new Runnable() {
@Override
public void run() {
myProcessingEnabled.waitFor();
}
});
}
public void startProcessing() {
if (!myProcessingEnabled.getAndSet(true)) {
super.processQueue();
}
}
@Override
protected void processQueue() {
if (myProcessingEnabled.get()) {
super.processQueue();
}
private void startProcessing() {
myProcessingEnabled.up();
}
}