Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

replaced synchronized TreeMap with ConcurrentSkipListMap

  • Loading branch information...
commit 91a15b04637759da127b0f58d3e7f30c6ccedb8a 1 parent bd8ca2c
Bela Ban authored

Showing 1 changed file with 6 additions and 11 deletions. Show diff stats Hide diff stats

  1. +6 11 src/org/jgroups/stack/RangeBasedRetransmitter.java
17 src/org/jgroups/stack/RangeBasedRetransmitter.java
@@ -6,6 +6,7 @@
6 6
7 7 import java.util.*;
8 8 import java.util.concurrent.ConcurrentHashMap;
  9 +import java.util.concurrent.ConcurrentSkipListMap;
9 10 import java.util.concurrent.atomic.AtomicLong;
10 11
11 12
@@ -27,7 +28,7 @@
27 28
28 29 // todo: when JDK 6 is the baseline, convert the TreeMap to a TreeSet or ConcurrentSkipListSet and use ceiling()
29 30 /** Sorted hashmap storing the ranges */
30   - private final Map<Seqno,Seqno> ranges=Collections.synchronizedSortedMap(new TreeMap<Seqno,Seqno>(new SeqnoComparator()));
  31 + private final Map<Seqno,Seqno> ranges=new ConcurrentSkipListMap<Seqno,Seqno>(new SeqnoComparator());
31 32
32 33 /** Association between ranges and retransmission tasks */
33 34 private final Map<Seqno,Task> tasks=new ConcurrentHashMap<Seqno,Task>();
@@ -149,11 +150,8 @@ public void reset() {
149 150 public String toString() {
150 151 int missing_msgs=0;
151 152
152   - synchronized(ranges) {
153   - for(Seqno range: ranges.keySet()) {
154   - missing_msgs+=range.getNumberOfMissingMessages();
155   - }
156   - }
  153 + for(Seqno range: ranges.keySet())
  154 + missing_msgs+=range.getNumberOfMissingMessages();
157 155
158 156 StringBuilder sb=new StringBuilder();
159 157 sb.append(missing_msgs).append(" messages to retransmit");
@@ -171,11 +169,8 @@ public String toString() {
171 169 public int size() {
172 170 int retval=0;
173 171
174   - synchronized(ranges) {
175   - for(Seqno range: ranges.keySet()) {
176   - retval+=range.getNumberOfMissingMessages();
177   - }
178   - }
  172 + for(Seqno range: ranges.keySet())
  173 + retval+=range.getNumberOfMissingMessages();
179 174 return retval;
180 175 }
181 176

0 comments on commit 91a15b0

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