mirror of
https://github.com/eclipse-cdt/cdt
synced 2025-03-28 14:56:28 +01:00
Clean up for synchronization of LaunchBarManager.descriptors
This change makes LaunchBarManager.descriptors a synchronized map, slightly reducing the extra code and complexity added for #262. Signed-off-by: Simeon Andreev <simeon.danailov.andreev@gmail.com>
This commit is contained in:
parent
5bb96b2f88
commit
eb083f8cdd
1 changed files with 6 additions and 15 deletions
|
@ -69,7 +69,8 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
private final Map<ILaunchDescriptorType, LaunchDescriptorTypeInfo> descriptorTypeInfo = new HashMap<>();
|
||||
private final Map<String, List<LaunchConfigProviderInfo>> configProviders = new HashMap<>();
|
||||
// Descriptors in MRU order, key is desc type id and desc name.
|
||||
private final Map<Pair<String, String>, ILaunchDescriptor> descriptors = new LinkedHashMap<>();
|
||||
private final Map<Pair<String, String>, ILaunchDescriptor> descriptors = Collections
|
||||
.synchronizedMap(new LinkedHashMap<>());
|
||||
// Map of launch objects to launch descriptors
|
||||
private final Map<Object, ILaunchDescriptor> objectDescriptorMap = new HashMap<>();
|
||||
private ILaunchTargetManager launchTargetManager;
|
||||
|
@ -307,9 +308,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
|
||||
private void addDescriptor(Object launchObject, ILaunchDescriptor descriptor) throws CoreException {
|
||||
Pair<String, String> descriptorId = getDescriptorId(descriptor);
|
||||
synchronized (descriptors) {
|
||||
descriptors.put(descriptorId, descriptor);
|
||||
}
|
||||
descriptors.put(descriptorId, descriptor);
|
||||
objectDescriptorMap.put(launchObject, descriptor);
|
||||
setActiveLaunchDescriptor(descriptor);
|
||||
}
|
||||
|
@ -377,9 +376,7 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
ILaunchDescriptor descriptor = objectDescriptorMap.remove(launchObject);
|
||||
if (descriptor != null) {
|
||||
Pair<String, String> descriptorId = getDescriptorId(descriptor);
|
||||
synchronized (descriptors) {
|
||||
descriptors.remove(descriptorId);
|
||||
}
|
||||
descriptors.remove(descriptorId);
|
||||
if (descriptor.equals(activeLaunchDesc)) {
|
||||
setActiveLaunchDescriptor(getLastUsedDescriptor());
|
||||
}
|
||||
|
@ -489,14 +486,8 @@ public class LaunchBarManager implements ILaunchBarManager, ILaunchTargetListene
|
|||
Activator.trace("resync for " + descriptor); //$NON-NLS-1$
|
||||
return;
|
||||
}
|
||||
if (descriptor != null) {
|
||||
boolean isContained;
|
||||
synchronized (descriptors) {
|
||||
isContained = descriptors.containsValue(descriptor);
|
||||
}
|
||||
if (!isContained) {
|
||||
throw new IllegalStateException(Messages.LaunchBarManager_1);
|
||||
}
|
||||
if (descriptor != null && !descriptors.containsValue(descriptor)) {
|
||||
throw new IllegalStateException(Messages.LaunchBarManager_1);
|
||||
}
|
||||
if (descriptor == null) {
|
||||
// do not set to null unless no descriptors
|
||||
|
|
Loading…
Add table
Reference in a new issue