Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

comment tweaks

git-svn-id: http://svn.codehaus.org/groovy/trunk/groovy/groovy-core@18795 a5544e8c-8a19-0410-ba12-f9af4593a198
  • Loading branch information...
commit 547f55790d0338b09fede88d3358efca5392b557 1 parent 0678e6b
Paul King paulk-asert authored
85 src/main/org/codehaus/groovy/runtime/metaclass/ConcurrentReaderHashMap.java
... ... @@ -1,32 +1,26 @@
1 1 /*
2   - File: ConcurrentReaderHashMap
3   -
4   - Written by Doug Lea. Adapted and released, under explicit
5   - permission, from JDK1.2 HashMap.java and Hashtable.java which
6   - carries the following copyright:
7   -
8   - * Copyright 1997 by Sun Microsystems, Inc.,
9   - * 901 San Antonio Road, Palo Alto, California, 94303, U.S.A.
10   - * All rights reserved.
11   - *
12   - * This software is the confidential and proprietary information
13   - * of Sun Microsystems, Inc. ("Confidential Information"). You
14   - * shall not disclose such Confidential Information and shall use
15   - * it only in accordance with the terms of the license agreement
16   - * you entered into with Sun.
17   -
18   - History:
19   - Date Who What
20   - 28oct1999 dl Created
21   - 14dec1999 dl jmm snapshot
22   - 19apr2000 dl use barrierLock
23   - 12jan2001 dl public release
24   - 17nov2001 dl Minor tunings
25   - 20may2002 dl BarrierLock can now be serialized.
26   - 09dec2002 dl Fix interference checks.
27   - 23jun2004 dl Avoid bad array sizings in view toArray methods
28   - 02jul2007 blackdrag adaption of package name to Groovy project
29   -*/
  2 + * Copyright 2003-2009 the original author or authors.
  3 + *
  4 + * Licensed under the Apache License, Version 2.0 (the "License");
  5 + * you may not use this file except in compliance with the License.
  6 + * You may obtain a copy of the License at
  7 + *
  8 + * http://www.apache.org/licenses/LICENSE-2.0
  9 + *
  10 + * Unless required by applicable law or agreed to in writing, software
  11 + * distributed under the License is distributed on an "AS IS" BASIS,
  12 + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  13 + * See the License for the specific language governing permissions and
  14 + * limitations under the License.
  15 + *
  16 + * Modified to support mostly-concurrent reading from this file:
  17 + * http://gee.cs.oswego.edu/cgi-bin/viewcvs.cgi/jsr166/src/main/java/util/concurrent/ConcurrentHashMap.java
  18 + * which contains the following license information:
  19 + *
  20 + * Written by Doug Lea with assistance from members of JCP JSR-166
  21 + * Expert Group and released to the public domain, as explained at
  22 + * http://creativecommons.org/licenses/publicdomain
  23 + */
30 24
31 25 package org.codehaus.groovy.runtime.metaclass;
32 26
@@ -44,9 +38,8 @@
44 38 import java.io.Serializable;
45 39 import java.io.IOException;
46 40
47   -
48 41 /**
49   - * A version of Hashtable that supports mostly-concurrent reading, but
  42 + * A hash table that supports mostly-concurrent reading, but
50 43 * exclusive writing. Because reads are not limited to periods
51 44 * without writes, a concurrent reader policy is weaker than a classic
52 45 * reader/writer policy, but is generally faster and allows more
@@ -173,7 +166,6 @@ the right table (which can change under resizes). If
173 166
174 167 * Remove() (also clear()) invalidates removed nodes to alert read
175 168 operations that they must wait out the full modifications.
176   -
177 169 */
178 170
179 171 /** A Serializable class for barrier lock **/
@@ -315,7 +307,7 @@ protected boolean eq(Object x, Object y) {
315 307 * @param loadFactor the load factor of the ConcurrentReaderHashMap
316 308 * @throws IllegalArgumentException if the initial maximum number
317 309 * of elements is less
318   - * than zero, or if the load factor is nonpositive.
  310 + * than zero, or if the load factor is non-positive.
319 311 */
320 312 public ConcurrentReaderHashMap(int initialCapacity, float loadFactor) {
321 313 if (loadFactor <= 0)
@@ -336,8 +328,7 @@ public ConcurrentReaderHashMap(int initialCapacity, float loadFactor) {
336 328 * @param initialCapacity the initial capacity of the
337 329 * ConcurrentReaderHashMap.
338 330 * @throws IllegalArgumentException if the initial maximum number
339   - * of elements is less
340   - * than zero.
  331 + * of elements is less than zero.
341 332 */
342 333 public ConcurrentReaderHashMap(int initialCapacity) {
343 334 this(initialCapacity, DEFAULT_LOAD_FACTOR);
@@ -389,8 +380,7 @@ public synchronized boolean isEmpty() {
389 380 * @return the value to which the key is mapped in this table;
390 381 * <code>null</code> if the key is not mapped to any value in
391 382 * this table.
392   - * @exception NullPointerException if the key is
393   - * <code>null</code>.
  383 + * @exception NullPointerException if the key is <code>null</code>.
394 384 * @see #put(Object, Object)
395 385 */
396 386 public Object get(Object key) {
@@ -435,9 +425,9 @@ else if (e.hash == hash && eq(key, e.key)) {
435 425 return value;
436 426
437 427 // Entry was invalidated during deletion. But it could
438   - // have been re-inserted, so we must retraverse.
  428 + // have been re-inserted, so we must re-traverse.
439 429 // To avoid useless contention, get lock to wait out modifications
440   - // before retraversing.
  430 + // before re-traversing.
441 431
442 432 synchronized(this) {
443 433 tab = table;
@@ -458,8 +448,7 @@ else if (e.hash == hash && eq(key, e.key)) {
458 448 * @return <code>true</code> if and only if the specified object
459 449 * is a key in this table, as determined by the
460 450 * <tt>equals</tt> method; <code>false</code> otherwise.
461   - * @exception NullPointerException if the key is
462   - * <code>null</code>.
  451 + * @exception NullPointerException if the key is <code>null</code>.
463 452 * @see #contains(Object)
464 453 */
465 454 public boolean containsKey(Object key) {
@@ -478,8 +467,7 @@ public boolean containsKey(Object key) {
478 467 * @param value the value.
479 468 * @return the previous value of the specified key in this table,
480 469 * or <code>null</code> if it did not have one.
481   - * @exception NullPointerException if the key or value is
482   - * <code>null</code>.
  470 + * @exception NullPointerException if the key or value is <code>null</code>.
483 471 * @see Object#equals(Object)
484 472 * @see #get(Object)
485 473 */
@@ -643,7 +631,7 @@ public Object remove(Object key) {
643 631 1. Set value field to null, to force get() to retry
644 632 2. Rebuild the list without this entry.
645 633 All entries following removed node can stay in list, but
646   - all preceeding ones need to be cloned. Traversals rely
  634 + all preceding ones need to be cloned. Traversals rely
647 635 on this strategy to ensure that elements will not be
648 636 repeated during iteration.
649 637 */
@@ -1143,7 +1131,7 @@ protected HashIterator() {
1143 1131 public boolean hasNext() {
1144 1132
1145 1133 /*
1146   - currentkey and currentValue are set here to ensure that next()
  1134 + currentKey and currentValue are set here to ensure that next()
1147 1135 returns normally if hasNext() returns true. This avoids
1148 1136 surprises especially when final element is removed during
1149 1137 traversal -- instead, we just ignore the removal during
@@ -1210,7 +1198,8 @@ public void remove() {
1210 1198 * instance to a stream (i.e.,
1211 1199 * serialize it).
1212 1200 *
1213   - * @serialData The <i>capacity</i> of the
  1201 + * @param s the stream
  1202 + * @serialData The <i>capacity</i> of the
1214 1203 * ConcurrentReaderHashMap (the length of the
1215 1204 * bucket array) is emitted (int), followed by the
1216 1205 * <i>size</i> of the ConcurrentReaderHashMap (the number of key-value
@@ -1245,6 +1234,8 @@ private synchronized void writeObject(java.io.ObjectOutputStream s)
1245 1234 * Reconstitute the <tt>ConcurrentReaderHashMap</tt>
1246 1235 * instance from a stream (i.e.,
1247 1236 * deserialize it).
  1237 + *
  1238 + * @param s the stream
1248 1239 */
1249 1240 private synchronized void readObject(java.io.ObjectInputStream s)
1250 1241 throws IOException, ClassNotFoundException {
@@ -1267,14 +1258,14 @@ private synchronized void readObject(java.io.ObjectInputStream s)
1267 1258 }
1268 1259
1269 1260 /**
1270   - * Return the number of slots in this table
  1261 + * @return the number of slots in this table
1271 1262 **/
1272 1263 public synchronized int capacity() {
1273 1264 return table.length;
1274 1265 }
1275 1266
1276 1267 /**
1277   - * Return the load factor
  1268 + * @return the load factor
1278 1269 **/
1279 1270 public float loadFactor() {
1280 1271 return loadFactor;

0 comments on commit 547f557

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