Skip to content
This repository has been archived by the owner on Apr 21, 2023. It is now read-only.

Commit

Permalink
Fixed the synchronization strategy
Browse files Browse the repository at this point in the history
Signed-off-by: nbhusare <[email protected]>
  • Loading branch information
nbhusare committed May 4, 2020
1 parent e02311a commit 76f94d1
Showing 1 changed file with 5 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
package org.eclipse.xtext.ide;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;

import org.eclipse.xtext.util.DisposableRegistry;
import org.eclipse.xtext.util.IDisposable;

import com.google.common.collect.Maps;
import com.google.inject.Inject;
import com.google.inject.Provider;
import com.google.inject.Singleton;
Expand All @@ -24,17 +24,18 @@
* Provider for executor services. By calling {@link #dispose()} all created executor services are shut down.
* <p>
* In some situations it is necessary to use multiple instances of executor services in order to avoid deadlocks. That
* can be achieved with the {@link #get(String)} method, which will return a different instance for each key.
* can be achieved with the {@link #get(String)} method, which will return a different instance for each key. </p>
*/
@Singleton
public class ExecutorServiceProvider implements Provider<ExecutorService>, IDisposable {

private final Map<String, ExecutorService> instanceCache = new ConcurrentHashMap<>(3);

@Inject
public void registerTo(DisposableRegistry disposableRegistry) {
disposableRegistry.register(this);
}

private final Map<String, ExecutorService> instanceCache = Maps.newHashMapWithExpectedSize(3);

@Override
public ExecutorService get() {
return get(null);
Expand Down

0 comments on commit 76f94d1

Please sign in to comment.