Class DefaultAttributeMap
java.lang.Object
io.netty.util.DefaultAttributeMap
- All Implemented Interfaces:
AttributeMap
- Direct Known Subclasses:
AbstractChannel, AbstractHttp2StreamChannel
Default
Attributes lookup and remove exibit
AttributeMap implementation which not exibit any blocking behaviour on attribute lookup while using a
copy-on-write approach on the modify path.Attributes lookup and remove exibit
O(logn) time worst-case
complexity, hence attribute::set(null) is to be preferred to remove.-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static final class -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate DefaultAttributeMap.DefaultAttribute[]private static final AtomicReferenceFieldUpdater<DefaultAttributeMap, DefaultAttributeMap.DefaultAttribute[]> private static final DefaultAttributeMap.DefaultAttribute[] -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescription<T> Attribute<T> attr(AttributeKey<T> key) Get theAttributefor the givenAttributeKey.<T> booleanhasAttr(AttributeKey<T> key) private static voidorderedCopyOnInsert(DefaultAttributeMap.DefaultAttribute[] sortedSrc, int srcLength, DefaultAttributeMap.DefaultAttribute[] copy, DefaultAttributeMap.DefaultAttribute toInsert) private <T> voidremoveAttributeIfMatch(AttributeKey<T> key, DefaultAttributeMap.DefaultAttribute<T> value) private static intsearchAttributeByKey(DefaultAttributeMap.DefaultAttribute[] sortedAttributes, AttributeKey<?> key) Similarly toArrays::binarySearchit perform a binary search optimized for this use case, in order to save polymorphic calls (on comparator side) and unnecessary class checks.
-
Field Details
-
ATTRIBUTES_UPDATER
private static final AtomicReferenceFieldUpdater<DefaultAttributeMap, DefaultAttributeMap.DefaultAttribute[]> ATTRIBUTES_UPDATER -
EMPTY_ATTRIBUTES
-
attributes
-
-
Constructor Details
-
DefaultAttributeMap
public DefaultAttributeMap()
-
-
Method Details
-
searchAttributeByKey
private static int searchAttributeByKey(DefaultAttributeMap.DefaultAttribute[] sortedAttributes, AttributeKey<?> key) Similarly toArrays::binarySearchit perform a binary search optimized for this use case, in order to save polymorphic calls (on comparator side) and unnecessary class checks. -
orderedCopyOnInsert
private static void orderedCopyOnInsert(DefaultAttributeMap.DefaultAttribute[] sortedSrc, int srcLength, DefaultAttributeMap.DefaultAttribute[] copy, DefaultAttributeMap.DefaultAttribute toInsert) -
attr
Description copied from interface:AttributeMapGet theAttributefor the givenAttributeKey. This method will never return null, but may return anAttributewhich does not have a value set yet.- Specified by:
attrin interfaceAttributeMap
-
hasAttr
Description copied from interface:AttributeMap- Specified by:
hasAttrin interfaceAttributeMap
-
removeAttributeIfMatch
private <T> void removeAttributeIfMatch(AttributeKey<T> key, DefaultAttributeMap.DefaultAttribute<T> value)
-