Overview | Package | Class
| FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## org.codehaus.groovy.runtime.metaclass
Class BarrierLock

A Serializable class for barrier lock *

Field Summary
`int` | `DEFAULT_INITIAL_CAPACITY`
`float` | `DEFAULT_LOAD_FACTOR`
`int` | `MAXIMUM_CAPACITY`
`int` | `MINIMUM_CAPACITY`
`BarrierLock` | `barrierLock`
`int` | `count`
`Set` | `entrySet`
`Set` | `keySet`
`Object` | `lastWrite`
`float` | `loadFactor`
`def` | `table`
`int` | `threshold`
`Collection` | `values`

Constructor Summary
`BarrierLock()`

Method Summary
`def` | `ConcurrentReaderHashMap(int initialCapacity, float loadFactor)` Constructs a new, empty map with the specified initial capacity and the specified load factor.
`def` | `ConcurrentReaderHashMap(int initialCapacity)` Constructs a new, empty map with the specified initial capacity and default load factor.
`def` | `ConcurrentReaderHashMap()` Constructs a new, empty map with a default initial capacity and load factor.
`def` | `ConcurrentReaderHashMap(Map t)` Constructs a new map with the same mappings as the given map.
`void` | `clear()` Removes all mappings from this map.
`Object` | `clone()` Returns a shallow copy of this `ConcurrentReaderHashMap` instance: the keys and values themselves are not cloned.
`boolean` | `contains(Object value)` Tests if some key maps into the specified value in this table.
`boolean` | `containsKey(Object key)` Tests if the specified object is a key in this table.
`boolean` | `containsValue(Object value)` Returns `true` if this map maps one or more keys to the specified value.
`boolean` | `eq(Object x, Object y)` Check for equality of non-null references x and y.
`Object` | `get(Object key)` Returns the value to which the specified key is mapped in this table.
`def` | `getTableForReading()` Get ref to table; the reference and the cells it accesses will be at least as fresh as from last use of barrierLock
`static int` | `hash(Object x)` Return hash code for Object x.
`boolean` | `isEmpty()` Returns `true` if this map contains no key-value mappings.
`Set` | `keySet()` Returns a set view of the keys contained in this map.
`int` | `p2capacity(int initialCapacity)` The default initial number of table slots for this table (32).
`Object` | `put(Object key, Object value)` Maps the specified `key` to the specified `value` in this table.
`void` | `putAll(Map t)` Copies all of the mappings from the specified map to this one.
`void` | `recordModification(Object x)` Lock used only for its memory effects.
`void` | `rehash()` Rehashes the contents of this map into a new table with a larger capacity.
`Object` | `remove(Object key)` Removes the key (and its corresponding value) from this table.
`int` | `size()` Returns the number of key-value mappings in this map.
`Object` | `sput(Object key, Object value, int hash)` Continuation of put(), called only when synch lock is held and interference has been detected.
`Object` | `sremove(Object key, int hash)` Continuation of remove(), called only when synch lock is held and interference has been detected.

Constructor Detail

### BarrierLock

    BarrierLock()

Method Detail

### ConcurrentReaderHashMap

    public def ConcurrentReaderHashMap(int initialCapacity, float loadFactor)

  Constructs a new, empty map with the specified initial capacity and the specified load factor.
  param:
    initialCapacity the initial capacity
  The actual initial capacity is rounded to the nearest power of two.
  param:
    loadFactor the load factor of the ConcurrentReaderHashMap
  throws:
    IllegalArgumentException if the initial maximum number
  of elements is less than zero, or if the load factor is nonpositive.

### ConcurrentReaderHashMap

    public def ConcurrentReaderHashMap(int initialCapacity)

  Constructs a new, empty map with the specified initial capacity and default load factor.
  param:
    initialCapacity the initial capacity of the
  ConcurrentReaderHashMap.
  throws:
    IllegalArgumentException if the initial maximum number
  of elements is less than zero.

### ConcurrentReaderHashMap

    public def ConcurrentReaderHashMap()

  Constructs a new, empty map with a default initial capacity and load factor.

### ConcurrentReaderHashMap

    public def ConcurrentReaderHashMap(Map t)

  Constructs a new map with the same mappings as the given map. The map is created with a capacity of twice the number of mappings in the given map or 16 (whichever is greater), and a default load factor.

### clear

    public void clear()

  Removes all mappings from this map.

### clone

    public Object clone()

  Returns a shallow copy of this `ConcurrentReaderHashMap` instance: the keys and values themselves are not cloned.
  return:
    a shallow copy of this map.

### contains

    public boolean contains(Object value)

  Tests if some key maps into the specified value in this table. This operation is more expensive than the `containsKey` method.

  Note that this method is identical in functionality to containsValue, (which is part of the Map interface in the collections framework).

  param:
    value a value to search for.
  return:
    `true` if and only if some key maps to the
  `value` argument in this table as determined by the `equals` method; `false` otherwise.
  exception:
    NullPointerException if the value is `null`.
  see:
    #containsKey(Object)
  see:
    #containsValue(Object)
  see:
    Map

### containsKey

    public boolean containsKey(Object key)

  Tests if the specified object is a key in this table.
  param:
    key possible key.
  return:
    `true` if and only if the specified object
  is a key in this table, as determined by the `equals` method; `false` otherwise.
  exception:
    NullPointerException if the key is
  `null`.
  see:
    #contains(Object)

### containsValue

    public boolean containsValue(Object value)

  Returns `true` if this map maps one or more keys to the specified value. Note: This method requires a full internal traversal of the hash table, and so is much slower than method `containsKey`.
  param:
    value value whose presence in this map is to be tested.
  return:
    `true` if this map maps one or more keys to the
  specified value.
  exception:
    NullPointerException if the value is `null`.

### eq

    boolean eq(Object x, Object y)

  Check for equality of non-null references x and y.

### get

    public Object get(Object key)

  Returns the value to which the specified key is mapped in this table.
  param:
    key a key in the table.
  return:
    the value to which the key is mapped in this table;
  `null` if the key is not mapped to any value in this table.
  exception:
    NullPointerException if the key is
  `null`.
  see:
    #put(Object, Object)

### getTableForReading

    def getTableForReading()

  Get ref to table; the reference and the cells it accesses will be at least as fresh as from last use of barrierLock

### hash

    static int hash(Object x)

  Return hash code for Object x. Since we are using power-of-two tables, it is worth the effort to improve hashcode via the same multiplicative scheme as used in IdentityHashMap.

### isEmpty

    public boolean isEmpty()

  Returns `true` if this map contains no key-value mappings.
  return:
    `true` if this map contains no key-value mappings.

### keySet

    public Set keySet()

  Returns a set view of the keys contained in this map. The set is backed by the map, so changes to the map are reflected in the set, and vice-versa. The set supports element removal, which removes the corresponding mapping from this map, via the `Iterator.remove`, `Set.remove`, `removeAll`, `retainAll`, and `clear` operations. It does not support the `add` or `addAll` operations.
  return:
    a set view of the keys contained in this map.

### p2capacity

    int p2capacity(int initialCapacity)

  The default initial number of table slots for this table (32). Used when not otherwise specified in constructor.

### put

    public Object put(Object key, Object value)

  Maps the specified `key` to the specified `value` in this table. Neither the key nor the value can be `null`.

  The value can be retrieved by calling the `get` method with a key that is equal to the original key.

  param:
    key the table key.
  param:
    value the value.
  return:
    the previous value of the specified key in this table,
  or `null` if it did not have one.
  exception:
    NullPointerException if the key or value is
  `null`.
  see:
    Object#equals(Object)
  see:
    #get(Object)

### putAll

    public void putAll(Map t)

  Copies all of the mappings from the specified map to this one. These mappings replace any mappings that this map had for any of the keys currently in the specified Map.
  param:
    t Mappings to be stored in this map.

### recordModification

    void recordModification(Object x)

  Lock used only for its memory effects.

### rehash

    void rehash()

  Rehashes the contents of this map into a new table with a larger capacity. This method is called automatically when the number of keys in this map exceeds its capacity and load factor.

### remove

    public Object remove(Object key)

  Removes the key (and its corresponding value) from this table. This method does nothing if the key is not in the table.
  param:
    key the key that needs to be removed.
  return:
    the value to which the key had been mapped in this table,
  or `null` if the key did not have a mapping.
  exception:
    NullPointerException if the key is
  `null`.

### size

    public int size()

  Returns the number of key-value mappings in this map.
  return:
    the number of key-value mappings in this map.

### sput

    Object sput(Object key, Object value, int hash)

  Continuation of put(), called only when synch lock is held and interference has been detected.

### sremove

    Object sremove(Object key, int hash)

  Continuation of remove(), called only when synch lock is held and interference has been detected.