Skip to content

Commit 7187a8c

Browse files
committed
Unify the logic for requesting sync
1 parent 564fa09 commit 7187a8c

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

base/src/com/google/idea/blaze/base/qsync/QuerySyncAsyncFileListener.java

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,6 @@ public interface SyncRequester {
173173
private static class QueueingSyncRequester implements SyncRequester {
174174
private final Project project;
175175

176-
private final AtomicBoolean changePending = new AtomicBoolean(false);
177176
private final ConcurrentLinkedQueue<VirtualFile> unprocessedChanges = new ConcurrentLinkedQueue<>();
178177

179178
public QueueingSyncRequester(Project project) {
@@ -192,9 +191,7 @@ public void afterQuerySync(Project project, BlazeContext context) {
192191
if (!requester.project.equals(project)) {
193192
return;
194193
}
195-
if (requester.changePending.get()) {
196-
requester.requestSyncInternal(ImmutableList.of());
197-
}
194+
requester.requestSync(ImmutableList.of());
198195
}
199196
},
200197
parentDisposable);
@@ -206,8 +203,9 @@ public void requestSync(@NotNull Collection<VirtualFile> files) {
206203
logger.info(String.format("Putting %d files into sync queue", files.size()));
207204
ImmutableList<VirtualFile> changesToProcess = ImmutableList.of();
208205
synchronized (unprocessedChanges) {
206+
// TODO aggregate multiple events into one sync request
209207
unprocessedChanges.addAll(files);
210-
if (changePending.compareAndSet(false, true)) {
208+
if (!unprocessedChanges.isEmpty()) {
211209
if (!BlazeSyncStatus.getInstance(project).syncInProgress()) {
212210
changesToProcess = ImmutableList.copyOf(unprocessedChanges);
213211
unprocessedChanges.clear();
@@ -220,12 +218,11 @@ public void requestSync(@NotNull Collection<VirtualFile> files) {
220218
}
221219

222220
private void requestSyncInternal(ImmutableCollection<VirtualFile> files) {
223-
logger.info(String.format("Requesting sync of %d files", files.size()));
221+
logger.info(String.format("Requesting sync of files: %s", files));
224222
QuerySyncManager.getInstance(project)
225223
.deltaSync(
226224
QuerySyncActionStatsScope.createForFiles(QuerySyncAsyncFileListener.class, null, files),
227225
TaskOrigin.AUTOMATIC);
228-
changePending.set(false);
229226
}
230227
}
231228

0 commit comments

Comments
 (0)