[vassalengine-svn-trunk] [vassalengine-svn] SF.net SVN: vassalengine:[7383] VASSAL-src/trunk
Brought to you by:
rodneykinney,
uckelman
From: <uck...@us...> - 2010-10-10 10:33:50
|
Revision: 7383 http://vassalengine.svn.sourceforge.net/vassalengine/?rev=7383&view=rev Author: uckelman Date: 2010-10-10 10:33:43 +0000 (Sun, 10 Oct 2010) Log Message: ----------- Merged uckelman-working@7377. Collapsed deprecated classes to extend their relocated versions. Modified Paths: -------------- VASSAL-src/trunk/src/VASSAL/tools/ConcurrentSoftHashMap.java Property Changed: ---------------- VASSAL-src/trunk/ Property changes on: VASSAL-src/trunk ___________________________________________________________________ Modified: svn:mergeinfo - /VASSAL-src/branches/3.1:4957,4960-4961,4984-4985,4988,4993,5004,5020,5041,5055,5059,5063-5065,5072-5073,5079,5084,5087,5098-5099,5133,5136,5138-5139,5156,5158,5161,5163,5166,5179-5181,5209,5260,5263,5274,5276,5280,5283-5290,5296,5298,5301-5450,5452-5456,5466-5467,5470,5473-5474,5479,5482,5488,5494-5495,5498,5502,5506,5510,5519,5525,5534,5540,5572,5575-5577,5582,5586,5588,5593,5595-5596,5599,5601,5721-5722,5726,5728-5729,5766-5767,5769,5771,5773,5793-5794,5812,5814,5816,5818,5820,5827,5833,5861,5863,5878,5880,5882,5892,5904,5912-5913,5916-5917,5920,5923-5924,5927,5939,5941,5943,5945,5955,5963,5965,5968,5989-5992,5994,5996-5997,5999,6003-6008,6012,6014,6021,6023,6026-6029,6039,6045,6047,6049,6056,6058-6059,6066-6067,6080,6093,6175,6213-6214,6253,6261,6264,6286,6366,6380,6382-6383,6391-6392,6467,6601,6879,6903,7070,7078,7086,7129,7168,7170-7231 /VASSAL-src/branches/bsmith:4567-4756 /VASSAL-src/branches/bsmith/3.2-working:5236 /VASSAL-src/branches/bsmith/merge-3:5153 /VASSAL-src/branches/jimcot-3-1:6390 /VASSAL-src/branches/jimcot-trunk:6475 /VASSAL-src/branches/kstevens:7117,7120-7121,7125-7126,7130-7200 /VASSAL-src/branches/mkiefte:4821-4822,4867 /VASSAL-src/branches/mkiefte-3.1:5424,6019,6777 /VASSAL-src/branches/mkiefte-3.2:4991 /VASSAL-src/branches/nio-fs:6115-6462 /VASSAL-src/branches/rk-jabber:5293 /VASSAL-src/branches/swampwallaby-3.1:5134,5150-5151,5155,5165,5199,5257,5279,5294-5295,5303,5307-5308,5311,5319-5320,5329,5332,5352,5370,5425,5465,5468,5725,5762-5765,5788,5801-5802,5808-5810,5825,5847,5876,5890,5903,5907,5922,5935-5938,5947,5958,5983-5984,5986-5987,6038,6062,6243,6258-6260,6285,6353 /VASSAL-src/branches/swampwallaby-work:4458,4776,4806-4807,4819,4823-4825,4975,5067,5093 /VASSAL-src/branches/swampwallaby-work2:4840,4847,4883,4975,4980,4994,4996,4999-5000,5002-5003,5028 /VASSAL-src/branches/swampwallaby-work3:5086 /VASSAL-src/branches/swampwallaby-work5:4713 /VASSAL-src/branches/swampwallaby-work6:4727,4729-4730,4737,4742-4743,4747,4752,4776 /VASSAL-src/branches/uckelman-3.1:5389,5391,5400-5401,5403-5406,5411-5412,5415,5484-5487,5492-5493,5500-5501,5504,5509,5516,5518,5534,5872-5915,6010-6012,6016,6020 /VASSAL-src/branches/uckelman-3.2:6484-6515,6519-6560,6570-6576,6888,6890,6894,6943 /VASSAL-src/branches/uckelman-findbugs:4869-4915 /VASSAL-src/branches/uckelman-slf4j:7216,7218,7220,7222 /VASSAL-src/branches/uckelman-test:5623,5626-5627,5631-5633,5692,5752,5783,5798-5799,6107 /VASSAL-src/branches/uckelman-tilecache:6026-6520 /VASSAL-src/branches/uckelman-trunk-fix:6943,6945-6946 /VASSAL-src/branches/uckelman-work:4285,4657-4708,4769-4775,4779,4790,4799,4808,4814-4815,4817,4826,4924,4928,4933,4940,4965,4967-4971,5326,5347,5360-5361,5366-5368 /VASSAL-src/branches/uckelman-working:7200,7243-7245,7249-7250,7254-7255,7257,7260-7264,7276-7335,7339-7341,7344-7346,7348,7354-7355,7357-7359,7362-7363,7365,7367-7371,7374 /VASSAL-src/branches/wlk0-3.1:6464 + /VASSAL-src/branches/3.1:4957,4960-4961,4984-4985,4988,4993,5004,5020,5041,5055,5059,5063-5065,5072-5073,5079,5084,5087,5098-5099,5133,5136,5138-5139,5156,5158,5161,5163,5166,5179-5181,5209,5260,5263,5274,5276,5280,5283-5290,5296,5298,5301-5450,5452-5456,5466-5467,5470,5473-5474,5479,5482,5488,5494-5495,5498,5502,5506,5510,5519,5525,5534,5540,5572,5575-5577,5582,5586,5588,5593,5595-5596,5599,5601,5721-5722,5726,5728-5729,5766-5767,5769,5771,5773,5793-5794,5812,5814,5816,5818,5820,5827,5833,5861,5863,5878,5880,5882,5892,5904,5912-5913,5916-5917,5920,5923-5924,5927,5939,5941,5943,5945,5955,5963,5965,5968,5989-5992,5994,5996-5997,5999,6003-6008,6012,6014,6021,6023,6026-6029,6039,6045,6047,6049,6056,6058-6059,6066-6067,6080,6093,6175,6213-6214,6253,6261,6264,6286,6366,6380,6382-6383,6391-6392,6467,6601,6879,6903,7070,7078,7086,7129,7168,7170-7231 /VASSAL-src/branches/bsmith:4567-4756 /VASSAL-src/branches/bsmith/3.2-working:5236 /VASSAL-src/branches/bsmith/merge-3:5153 /VASSAL-src/branches/jimcot-3-1:6390 /VASSAL-src/branches/jimcot-trunk:6475 /VASSAL-src/branches/kstevens:7117,7120-7121,7125-7126,7130-7200 /VASSAL-src/branches/mkiefte:4821-4822,4867 /VASSAL-src/branches/mkiefte-3.1:5424,6019,6777 /VASSAL-src/branches/mkiefte-3.2:4991 /VASSAL-src/branches/nio-fs:6115-6462 /VASSAL-src/branches/rk-jabber:5293 /VASSAL-src/branches/swampwallaby-3.1:5134,5150-5151,5155,5165,5199,5257,5279,5294-5295,5303,5307-5308,5311,5319-5320,5329,5332,5352,5370,5425,5465,5468,5725,5762-5765,5788,5801-5802,5808-5810,5825,5847,5876,5890,5903,5907,5922,5935-5938,5947,5958,5983-5984,5986-5987,6038,6062,6243,6258-6260,6285,6353 /VASSAL-src/branches/swampwallaby-work:4458,4776,4806-4807,4819,4823-4825,4975,5067,5093 /VASSAL-src/branches/swampwallaby-work2:4840,4847,4883,4975,4980,4994,4996,4999-5000,5002-5003,5028 /VASSAL-src/branches/swampwallaby-work3:5086 /VASSAL-src/branches/swampwallaby-work5:4713 /VASSAL-src/branches/swampwallaby-work6:4727,4729-4730,4737,4742-4743,4747,4752,4776 /VASSAL-src/branches/uckelman-3.1:5389,5391,5400-5401,5403-5406,5411-5412,5415,5484-5487,5492-5493,5500-5501,5504,5509,5516,5518,5534,5872-5915,6010-6012,6016,6020 /VASSAL-src/branches/uckelman-3.2:6484-6515,6519-6560,6570-6576,6888,6890,6894,6943 /VASSAL-src/branches/uckelman-findbugs:4869-4915 /VASSAL-src/branches/uckelman-slf4j:7216,7218,7220,7222 /VASSAL-src/branches/uckelman-test:5623,5626-5627,5631-5633,5692,5752,5783,5798-5799,6107 /VASSAL-src/branches/uckelman-tilecache:6026-6520 /VASSAL-src/branches/uckelman-trunk-fix:6943,6945-6946 /VASSAL-src/branches/uckelman-work:4285,4657-4708,4769-4775,4779,4790,4799,4808,4814-4815,4817,4826,4924,4928,4933,4940,4965,4967-4971,5326,5347,5360-5361,5366-5368 /VASSAL-src/branches/uckelman-working:7200,7243-7245,7249-7250,7254-7255,7257,7260-7264,7276-7335,7339-7341,7344-7346,7348,7354-7355,7357-7359,7362-7363,7365,7367-7371,7374,7376-7379 /VASSAL-src/branches/wlk0-3.1:6464 Modified: VASSAL-src/trunk/src/VASSAL/tools/ConcurrentSoftHashMap.java =================================================================== --- VASSAL-src/trunk/src/VASSAL/tools/ConcurrentSoftHashMap.java 2010-10-10 10:31:53 UTC (rev 7382) +++ VASSAL-src/trunk/src/VASSAL/tools/ConcurrentSoftHashMap.java 2010-10-10 10:33:43 UTC (rev 7383) @@ -19,16 +19,6 @@ package VASSAL.tools; -import java.lang.ref.ReferenceQueue; -import java.lang.ref.SoftReference; -import java.util.AbstractMap; -import java.util.AbstractSet; -import java.util.Iterator; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.ConcurrentMap; - /** * A memory-sensitive {@link ConcurrentMap} which stores the values * in {@link SoftReference}s. This <code>ConcurrentMap</code> grows @@ -50,269 +40,6 @@ * @author Joel Uckelman */ @Deprecated -public class ConcurrentSoftHashMap<K,V> extends AbstractMap<K,V> - implements ConcurrentMap<K,V> { - - private static final class SoftValue<K,V> extends SoftReference<V> { - private final K key; - - private SoftValue(K key, V value, ReferenceQueue<V> queue) { - super(value, queue); - this.key = key; - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - if (o == null || o.getClass() != this.getClass()) return false; - final SoftValue sv = (SoftValue) o; - return key.equals(sv.key) && - get() == null ? sv.get() == null : get().equals(sv.get()); - } - - @Override - public int hashCode() { - return get() == null ? 0 : get().hashCode(); - } - } - - private final ConcurrentMap<K,SoftValue<K,V>> map = - new ConcurrentHashMap<K,SoftValue<K,V>>(); - - private final ReferenceQueue<V> queue = new ReferenceQueue<V>(); - - @SuppressWarnings("unchecked") - private void processQueue() { - SoftValue<K,V> sv; - // The ReferenceQueue API is broken. ReferenceQueue<T>.poll() - // returns a Reference<? extends T>. WTF? How could you ever use - // this without having to cast back to the kind of Reference - // you put in? - while ((sv = (SoftValue<K,V>) queue.poll()) != null) { - map.remove(sv.key, sv); -// System.out.println("Hasta la vista, " + sv.key + "."); - } -// System.out.println("Cache size = " + map.size()); - } - - // Query Operations - - /** {@inheritDoc} */ - @Override - public int size() { - processQueue(); - return map.size(); - } - - /** {@inheritDoc} */ - @Override - public boolean containsKey(Object key) { - if (key == null) - throw new NullPointerException(); - - processQueue(); - return map.containsKey(key); - } - - /** {@inheritDoc} */ - @Override - public V get(Object key) { - if (key == null) - throw new NullPointerException(); - - final SoftValue<K,V> sv = map.get(key); - if (sv != null) { - final V value = sv.get(); - if (value == null) { - map.remove(key, sv); - } - return value; - } - return null; - } - - // Modification Operations - - /** {@inheritDoc} */ - @Override - public V put(K key, V value) { - if (key == null) - throw new NullPointerException(); - if (value == null) - throw new NullPointerException(); - - processQueue(); - final SoftValue<K,V> oldSV = - map.put(key, new SoftValue<K,V>(key, value, queue)); - return oldSV == null ? null : oldSV.get(); - } - - /** {@inheritDoc} */ - @Override - public V remove(Object key) { - if (key == null) - throw new NullPointerException(); - - processQueue(); - final SoftValue<K,V> oldSV = map.remove(key); - return oldSV == null ? null : oldSV.get(); - } - - // Bulk Operations - - /** {@inheritDoc} */ - @Override - public void clear() { - map.clear(); - while (queue.poll() != null); - } - - // Views - - private Set<Map.Entry<K,V>> entrySet; - - /** - * An implementation of {@link Map.Entry}. Remove this and use - * {@link AbstractMap.SimpleEntry} with 1.6+. - */ - public static class SimpleEntry<K,V> implements Entry<K,V> { - private final K key; - private V value; - - public SimpleEntry(K key, V value) { - this.key = key; - this.value = value; - } - - public SimpleEntry(Entry<? extends K, ? extends V> entry) { - this.key = entry.getKey(); - this.value = entry.getValue(); - } - - public K getKey() { - return key; - } - - public V getValue() { - return value; - } - - public V setValue(V value) { - V oldValue = this.value; - this.value = value; - return oldValue; - } - - public boolean equals(Object o) { - if (!(o instanceof Map.Entry)) return false; - Map.Entry e = (Map.Entry)o; - return eq(key, e.getKey()) && eq(value, e.getValue()); - } - - public int hashCode() { - return (key == null ? 0 : key.hashCode()) ^ - (value == null ? 0 : value.hashCode()); - } - - public String toString() { - return key + "=" + value; - } - - private static boolean eq(Object o1, Object o2) { - return o1 == null ? o2 == null : o1.equals(o2); - } - } - - /** {@inheritDoc} */ - public Set<Map.Entry<K, V>> entrySet() { - processQueue(); - - if (entrySet == null) { - entrySet = new AbstractSet<Map.Entry<K,V>>() { - public Iterator<Map.Entry<K,V>> iterator() { - return new Iterator<Map.Entry<K,V>>() { - private final Iterator<Map.Entry<K,SoftValue<K,V>>> i = - map.entrySet().iterator(); - - public boolean hasNext() { - return i.hasNext(); - } - - public Map.Entry<K,V> next() { - final Map.Entry<K,SoftValue<K,V>> e = i.next(); - return new SimpleEntry<K,V>(e.getKey(), e.getValue().get()); - } - - public void remove() { - i.remove(); - } - }; - } - - public int size() { - return ConcurrentSoftHashMap.this.size(); - } - - public boolean contains(Object v) { - return ConcurrentSoftHashMap.this.containsValue(v); - } - }; - } - - return entrySet; - } - - // Concurrent Operations - - /** {@inheritDoc} */ - public V putIfAbsent(K key, V value) { - if (key == null) - throw new NullPointerException(); - if (value == null) - throw new NullPointerException(); - - processQueue(); - final SoftValue<K,V> oldSV = - map.putIfAbsent(key, new SoftValue<K,V>(key, value, queue)); - return oldSV == null ? null : oldSV.get(); - } - - /** {@inheritDoc} */ - public boolean remove(Object key, Object value) { - if (key == null) - throw new NullPointerException(); - if (value == null) - throw new NullPointerException(); - - processQueue(); - return map.remove(key, new SoftValue<Object,Object>(key, value, null)); - } - - /** {@inheritDoc} */ - public boolean replace(K key, V oldValue, V newValue) { - if (key == null) - throw new NullPointerException(); - if (oldValue == null) - throw new NullPointerException(); - if (newValue == null) - throw new NullPointerException(); - - processQueue(); - return map.replace(key, - new SoftValue<K,V>(key, oldValue, null), - new SoftValue<K,V>(key, newValue, queue)); - } - - /** {@inheritDoc} */ - public V replace(K key, V value) { - if (key == null) - throw new NullPointerException(); - if (value == null) - throw new NullPointerException(); - - processQueue(); - final SoftValue<K,V> oldSV = - map.replace(key, new SoftValue<K,V>(key, value, queue)); - return oldSV == null ? null : oldSV.get(); - } +public class ConcurrentSoftHashMap<K,V> + extends VASSAL.tools.concurrent.ConcurrentSoftHashMap<K,V> { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. ------------------------------------------------------------------------------ Beautiful is writing same markup. Internet Explorer 9 supports standards for HTML5, CSS3, SVG 1.1, ECMAScript5, and DOM L2 & L3. Spend less time writing and rewriting code and more time creating great experiences on the web. Be a part of the beta today. http://p.sf.net/sfu/beautyoftheweb _______________________________________________ vassalengine-svn mailing list vas...@li... https://lists.sourceforge.net/lists/listinfo/vassalengine-svn |