Mercurial > projects > dwt-addons
comparison dwtx/dwtxhelper/Collection.d @ 199:eb98a5cbfd78
Fix: potential problem with synchronized, thx torhu.
author | Frank Benoit <benoit@tionex.de> |
---|---|
date | Fri, 13 Mar 2009 17:03:26 +0100 |
parents | 489eb3f36068 |
children |
comparison
equal
deleted
inserted
replaced
198:489eb3f36068 | 199:eb98a5cbfd78 |
---|---|
2496 } | 2496 } |
2497 static class SynchronizedList : List { | 2497 static class SynchronizedList : List { |
2498 private List list; | 2498 private List list; |
2499 private this( List list ){ this.list = list; } | 2499 private this( List list ){ this.list = list; } |
2500 // Collection | 2500 // Collection |
2501 public int opApply (int delegate(ref Object value) dg){ synchronized{ return this.list.opApply(dg); } } | 2501 public int opApply (int delegate(ref Object value) dg){ synchronized(this){ return this.list.opApply(dg); } } |
2502 // List | 2502 // List |
2503 public void add(int index, Object element){ synchronized{ return this.list.add(index, element); } } | 2503 public void add(int index, Object element){ synchronized(this){ return this.list.add(index, element); } } |
2504 public bool add(Object o){ synchronized{ return this.list.add(o); } } | 2504 public bool add(Object o){ synchronized(this){ return this.list.add(o); } } |
2505 public bool add(String o){ synchronized{ return this.list.add(o); } } | 2505 public bool add(String o){ synchronized(this){ return this.list.add(o); } } |
2506 public bool addAll(Collection c){ synchronized{ return this.list.addAll(c); } } | 2506 public bool addAll(Collection c){ synchronized(this){ return this.list.addAll(c); } } |
2507 public bool addAll(int index, Collection c){ synchronized{ return this.list.addAll(index, c); } } | 2507 public bool addAll(int index, Collection c){ synchronized(this){ return this.list.addAll(index, c); } } |
2508 public void clear(){ synchronized{ return this.list.clear(); } } | 2508 public void clear(){ synchronized(this){ return this.list.clear(); } } |
2509 public bool contains(Object o){ synchronized{ return this.list.contains(o); } } | 2509 public bool contains(Object o){ synchronized(this){ return this.list.contains(o); } } |
2510 public bool contains(String o){ synchronized{ return this.list.contains(o); } } | 2510 public bool contains(String o){ synchronized(this){ return this.list.contains(o); } } |
2511 public bool containsAll(Collection c){ synchronized{ return this.list.containsAll(c); } } | 2511 public bool containsAll(Collection c){ synchronized(this){ return this.list.containsAll(c); } } |
2512 public int opEquals(Object o){ synchronized{ return this.list.opEquals(o); } } | 2512 public int opEquals(Object o){ synchronized(this){ return this.list.opEquals(o); } } |
2513 public Object get(int index){ synchronized{ return this.list.get(index); } } | 2513 public Object get(int index){ synchronized(this){ return this.list.get(index); } } |
2514 public hash_t toHash(){ synchronized{ return this.list.toHash(); } } | 2514 public hash_t toHash(){ synchronized(this){ return this.list.toHash(); } } |
2515 public int indexOf(Object o){ synchronized{ return this.list.indexOf(o); } } | 2515 public int indexOf(Object o){ synchronized(this){ return this.list.indexOf(o); } } |
2516 public bool isEmpty(){ synchronized{ return this.list.isEmpty(); } } | 2516 public bool isEmpty(){ synchronized(this){ return this.list.isEmpty(); } } |
2517 public Iterator iterator(){ synchronized{ return this.list.iterator(); } } | 2517 public Iterator iterator(){ synchronized(this){ return this.list.iterator(); } } |
2518 public int lastIndexOf(Object o){ synchronized{ return this.list.lastIndexOf(o); } } | 2518 public int lastIndexOf(Object o){ synchronized(this){ return this.list.lastIndexOf(o); } } |
2519 public ListIterator listIterator(){ synchronized{ return this.list.listIterator(); } } | 2519 public ListIterator listIterator(){ synchronized(this){ return this.list.listIterator(); } } |
2520 public ListIterator listIterator(int index){ synchronized{ return this.list.listIterator(index); } } | 2520 public ListIterator listIterator(int index){ synchronized(this){ return this.list.listIterator(index); } } |
2521 public Object remove(int index){ synchronized{ return this.list.remove(index); } } | 2521 public Object remove(int index){ synchronized(this){ return this.list.remove(index); } } |
2522 public bool remove(Object o){ synchronized{ return this.list.remove(o); } } | 2522 public bool remove(Object o){ synchronized(this){ return this.list.remove(o); } } |
2523 public bool remove(String o){ synchronized{ return this.list.remove(o); } } | 2523 public bool remove(String o){ synchronized(this){ return this.list.remove(o); } } |
2524 public bool removeAll(Collection c){ synchronized{ return this.list.removeAll(c); } } | 2524 public bool removeAll(Collection c){ synchronized(this){ return this.list.removeAll(c); } } |
2525 public bool retainAll(Collection c){ synchronized{ return this.list.retainAll(c); } } | 2525 public bool retainAll(Collection c){ synchronized(this){ return this.list.retainAll(c); } } |
2526 public Object set(int index, Object element){ synchronized{ return this.list.set(index,element); } } | 2526 public Object set(int index, Object element){ synchronized(this){ return this.list.set(index,element); } } |
2527 public int size(){ synchronized{ return this.list.size(); } } | 2527 public int size(){ synchronized(this){ return this.list.size(); } } |
2528 public List subList(int fromIndex, int toIndex){ synchronized{ return this.list.subList(fromIndex,toIndex); } } | 2528 public List subList(int fromIndex, int toIndex){ synchronized(this){ return this.list.subList(fromIndex,toIndex); } } |
2529 public Object[] toArray(){ synchronized{ return this.list.toArray(); } } | 2529 public Object[] toArray(){ synchronized(this){ return this.list.toArray(); } } |
2530 public Object[] toArray(Object[] a){ synchronized{ return this.list.toArray(a); } } | 2530 public Object[] toArray(Object[] a){ synchronized(this){ return this.list.toArray(a); } } |
2531 } | 2531 } |
2532 static List synchronizedList(List list){ | 2532 static List synchronizedList(List list){ |
2533 return new SynchronizedList(list); | 2533 return new SynchronizedList(list); |
2534 } | 2534 } |
2535 | 2535 |
2543 // Object setValue(Object value); | 2543 // Object setValue(Object value); |
2544 //} | 2544 //} |
2545 private this( Map map ){ | 2545 private this( Map map ){ |
2546 this.map = map; | 2546 this.map = map; |
2547 } | 2547 } |
2548 public void clear(){ synchronized{ this.map.clear(); } } | 2548 public void clear(){ synchronized(this){ this.map.clear(); } } |
2549 public bool containsKey(Object key){ synchronized{ return this.map.containsKey(key); } } | 2549 public bool containsKey(Object key){ synchronized(this){ return this.map.containsKey(key); } } |
2550 public bool containsKey(String key){ synchronized{ return this.map.containsKey(key); } } | 2550 public bool containsKey(String key){ synchronized(this){ return this.map.containsKey(key); } } |
2551 public bool containsValue(Object value){ synchronized{ return this.map.containsValue(value); } } | 2551 public bool containsValue(Object value){ synchronized(this){ return this.map.containsValue(value); } } |
2552 public Set entrySet(){ synchronized{ return this.map.entrySet(); } } | 2552 public Set entrySet(){ synchronized(this){ return this.map.entrySet(); } } |
2553 public int opEquals(Object o){ synchronized{ return this.map.opEquals(o); } } | 2553 public int opEquals(Object o){ synchronized(this){ return this.map.opEquals(o); } } |
2554 public Object get(Object key){ synchronized{ return this.map.get(key); } } | 2554 public Object get(Object key){ synchronized(this){ return this.map.get(key); } } |
2555 public Object get(String key){ synchronized{ return this.map.get(key); } } | 2555 public Object get(String key){ synchronized(this){ return this.map.get(key); } } |
2556 public hash_t toHash(){ synchronized{ return this.map.toHash(); } } | 2556 public hash_t toHash(){ synchronized(this){ return this.map.toHash(); } } |
2557 public bool isEmpty(){ synchronized{ return this.map.isEmpty(); } } | 2557 public bool isEmpty(){ synchronized(this){ return this.map.isEmpty(); } } |
2558 public Set keySet(){ synchronized{ return this.map.keySet(); } } | 2558 public Set keySet(){ synchronized(this){ return this.map.keySet(); } } |
2559 public Object put(Object key, Object value){ synchronized{ return this.map.put(key,value); } } | 2559 public Object put(Object key, Object value){ synchronized(this){ return this.map.put(key,value); } } |
2560 public Object put(String key, Object value){ synchronized{ return this.map.put(key,value); } } | 2560 public Object put(String key, Object value){ synchronized(this){ return this.map.put(key,value); } } |
2561 public Object put(Object key, String value){ synchronized{ return this.map.put(key,value); } } | 2561 public Object put(Object key, String value){ synchronized(this){ return this.map.put(key,value); } } |
2562 public Object put(String key, String value){ synchronized{ return this.map.put(key,value); } } | 2562 public Object put(String key, String value){ synchronized(this){ return this.map.put(key,value); } } |
2563 public void putAll(Map t){ synchronized{ return this.map.putAll(t); } } | 2563 public void putAll(Map t){ synchronized(this){ return this.map.putAll(t); } } |
2564 public Object remove(Object key){ synchronized{ return this.map.remove(key); } } | 2564 public Object remove(Object key){ synchronized(this){ return this.map.remove(key); } } |
2565 public Object remove(String key){ synchronized{ return this.map.remove(key); } } | 2565 public Object remove(String key){ synchronized(this){ return this.map.remove(key); } } |
2566 public int size(){ synchronized{ return this.map.size(); } } | 2566 public int size(){ synchronized(this){ return this.map.size(); } } |
2567 public Collection values(){ synchronized{ return this.map.values(); } } | 2567 public Collection values(){ synchronized(this){ return this.map.values(); } } |
2568 | 2568 |
2569 // only for D | 2569 // only for D |
2570 public int opApply (int delegate(ref Object value) dg){ synchronized{ return this.map.opApply( dg ); } } | 2570 public int opApply (int delegate(ref Object value) dg){ synchronized(this){ return this.map.opApply( dg ); } } |
2571 public int opApply (int delegate(ref Object key, ref Object value) dg){ synchronized{ return this.map.opApply( dg ); } } | 2571 public int opApply (int delegate(ref Object key, ref Object value) dg){ synchronized(this){ return this.map.opApply( dg ); } } |
2572 } | 2572 } |
2573 static Map synchronizedMap(Map m){ | 2573 static Map synchronizedMap(Map m){ |
2574 return new SynchronizedMap(m); | 2574 return new SynchronizedMap(m); |
2575 } | 2575 } |
2576 static Set synchronizedSet(Set s){ | 2576 static Set synchronizedSet(Set s){ |