org.hibernate.service.internal
Class ConcurrentServiceBinding<K,V>

java.lang.Object
  extended by org.hibernate.service.internal.ConcurrentServiceBinding<K,V>

public class ConcurrentServiceBinding<K,V>
extends Object

Since Service lookup is a very hot operation and essentially it's a read only data structure, to achieve threadsafety we can use immutability. For our use case we just need reference equality, and the expectation is that a limited number of elements will be contained in this custom collection (<32). So the following structure is functionally equivalent to an Identity based ConcurrentMap, but heavily tuned for reads, at cost of structural reorganization at writes. The implementation is a binary tree basing the comparison order on the identityHashCode of each key.


Constructor Summary
ConcurrentServiceBinding()
           
 
Method Summary
 void clear()
           
 V get(K key)
           
protected  int hashKey(K key)
           
 void put(K key, V value)
           
 Iterable<V> values()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ConcurrentServiceBinding

public ConcurrentServiceBinding()
Method Detail

clear

public void clear()

put

public void put(K key,
                V value)

get

public V get(K key)

hashKey

protected int hashKey(K key)

values

public Iterable<V> values()


Copyright © 2001-2015 Red Hat, Inc. All Rights Reserved.