Changeset 11029 in josm


Ignore:
Timestamp:
2016-09-19T19:21:49+02:00 (8 years ago)
Author:
michael2402
Message:

MapView: Use AtomicBoolean instead of custom synchronization.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/MapView.java

    r11028 r11029  
    2929import java.util.TreeSet;
    3030import java.util.concurrent.CopyOnWriteArrayList;
     31import java.util.concurrent.atomic.AtomicBoolean;
    3132
    3233import javax.swing.AbstractButton;
     
    215216    private final transient List<Layer> nonChangedLayers = new ArrayList<>();
    216217    private int lastViewID;
    217     private boolean paintPreferencesChanged = true;
     218    private AtomicBoolean paintPreferencesChanged = new AtomicBoolean(true);
    218219    private Rectangle lastClipBounds = new Rectangle();
    219220    private transient MapMover mapMover;
     
    466467        }
    467468
    468         boolean canUseBuffer;
    469 
    470         synchronized (this) {
    471             canUseBuffer = !paintPreferencesChanged;
    472             paintPreferencesChanged = false;
    473         }
    474         canUseBuffer = canUseBuffer
     469        boolean canUseBuffer = !paintPreferencesChanged.getAndSet(false)
    475470                && nonChangedLayers.size() <= nonChangedLayersCount
    476471                && lastViewID == getViewID()
     
    711706    @Override
    712707    public void preferenceChanged(PreferenceChangeEvent e) {
    713         synchronized (this) {
    714             paintPreferencesChanged = true;
    715         }
     708        paintPreferencesChanged.set(true);
    716709    }
    717710
Note: See TracChangeset for help on using the changeset viewer.