Skip to content
Browse files

replaced synchronized TreeMap with ConcurrentSkipListMap

  • Loading branch information...
1 parent bd8ca2c commit 91a15b04637759da127b0f58d3e7f30c6ccedb8a @belaban committed Dec 14, 2010
Showing with 6 additions and 11 deletions.
  1. +6 −11 src/org/jgroups/stack/RangeBasedRetransmitter.java
View
17 src/org/jgroups/stack/RangeBasedRetransmitter.java
@@ -6,6 +6,7 @@
import java.util.*;
import java.util.concurrent.ConcurrentHashMap;
+import java.util.concurrent.ConcurrentSkipListMap;
import java.util.concurrent.atomic.AtomicLong;
@@ -27,7 +28,7 @@
// todo: when JDK 6 is the baseline, convert the TreeMap to a TreeSet or ConcurrentSkipListSet and use ceiling()
/** Sorted hashmap storing the ranges */
- private final Map<Seqno,Seqno> ranges=Collections.synchronizedSortedMap(new TreeMap<Seqno,Seqno>(new SeqnoComparator()));
+ private final Map<Seqno,Seqno> ranges=new ConcurrentSkipListMap<Seqno,Seqno>(new SeqnoComparator());
/** Association between ranges and retransmission tasks */
private final Map<Seqno,Task> tasks=new ConcurrentHashMap<Seqno,Task>();
@@ -149,11 +150,8 @@ public void reset() {
public String toString() {
int missing_msgs=0;
- synchronized(ranges) {
- for(Seqno range: ranges.keySet()) {
- missing_msgs+=range.getNumberOfMissingMessages();
- }
- }
+ for(Seqno range: ranges.keySet())
+ missing_msgs+=range.getNumberOfMissingMessages();
StringBuilder sb=new StringBuilder();
sb.append(missing_msgs).append(" messages to retransmit");
@@ -171,11 +169,8 @@ public String toString() {
public int size() {
int retval=0;
- synchronized(ranges) {
- for(Seqno range: ranges.keySet()) {
- retval+=range.getNumberOfMissingMessages();
- }
- }
+ for(Seqno range: ranges.keySet())
+ retval+=range.getNumberOfMissingMessages();
return retval;
}

0 comments on commit 91a15b0

Please sign in to comment.
Something went wrong with that request. Please try again.