Class DefaultAttributeMap.DefaultAttribute<T>
- java.lang.Object
-
- java.util.concurrent.atomic.AtomicReference<T>
-
- io.netty.util.DefaultAttributeMap.DefaultAttribute<T>
-
- All Implemented Interfaces:
Attribute<T>,java.io.Serializable
- Enclosing class:
- DefaultAttributeMap
private static final class DefaultAttributeMap.DefaultAttribute<T> extends java.util.concurrent.atomic.AtomicReference<T> implements Attribute<T>
-
-
Field Summary
Fields Modifier and Type Field Description private DefaultAttributeMap.DefaultAttribute<?>headprivate AttributeKey<T>keyprivate DefaultAttributeMap.DefaultAttribute<?>nextprivate DefaultAttributeMap.DefaultAttribute<?>prevprivate booleanremovedprivate static longserialVersionUID
-
Constructor Summary
Constructors Constructor Description DefaultAttribute()DefaultAttribute(DefaultAttributeMap.DefaultAttribute<?> head, AttributeKey<T> key)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description TgetAndRemove()Removes this attribute from theAttributeMapand returns the old value.AttributeKey<T>key()Returns the key of this attribute.voidremove()Removes this attribute from theAttributeMap.private voidremove0()TsetIfAbsent(T value)Atomically sets to the given value if thisAttribute's value isnull.-
Methods inherited from class java.util.concurrent.atomic.AtomicReference
accumulateAndGet, compareAndExchange, compareAndExchangeAcquire, compareAndExchangeRelease, compareAndSet, get, getAcquire, getAndAccumulate, getAndSet, getAndUpdate, getOpaque, getPlain, lazySet, set, setOpaque, setPlain, setRelease, toString, updateAndGet, weakCompareAndSet, weakCompareAndSetAcquire, weakCompareAndSetPlain, weakCompareAndSetRelease, weakCompareAndSetVolatile
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
-
Methods inherited from interface io.netty.util.Attribute
compareAndSet, get, getAndSet, set
-
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
head
private final DefaultAttributeMap.DefaultAttribute<?> head
-
key
private final AttributeKey<T> key
-
prev
private DefaultAttributeMap.DefaultAttribute<?> prev
-
next
private DefaultAttributeMap.DefaultAttribute<?> next
-
removed
private volatile boolean removed
-
-
Constructor Detail
-
DefaultAttribute
DefaultAttribute(DefaultAttributeMap.DefaultAttribute<?> head, AttributeKey<T> key)
-
DefaultAttribute
DefaultAttribute()
-
-
Method Detail
-
key
public AttributeKey<T> key()
Description copied from interface:AttributeReturns the key of this attribute.
-
setIfAbsent
public T setIfAbsent(T value)
Description copied from interface:AttributeAtomically sets to the given value if thisAttribute's value isnull. If it was not possible to set the value as it contains a value it will just return the current value.- Specified by:
setIfAbsentin interfaceAttribute<T>
-
getAndRemove
public T getAndRemove()
Description copied from interface:AttributeRemoves this attribute from theAttributeMapand returns the old value. SubsequentAttribute.get()calls will returnnull. If you only want to return the old value and clear theAttributewhile still keep it in theAttributeMapuseAttribute.getAndSet(Object)with a value ofnull.Be aware that even if you call this method another thread that has obtained a reference to this
AttributeviaAttributeMap.attr(AttributeKey)will still operate on the same instance. That said if now another thread or even the same thread later will callAttributeMap.attr(AttributeKey)again, a newAttributeinstance is created and so is not the same as the previous one that was removed. Because of this special caution should be taken when you callAttribute.remove()orAttribute.getAndRemove().- Specified by:
getAndRemovein interfaceAttribute<T>
-
remove
public void remove()
Description copied from interface:AttributeRemoves this attribute from theAttributeMap. SubsequentAttribute.get()calls will return @{code null}. If you only want to remove the value and clear theAttributewhile still keep it inAttributeMapuseAttribute.set(Object)with a value ofnull.Be aware that even if you call this method another thread that has obtained a reference to this
AttributeviaAttributeMap.attr(AttributeKey)will still operate on the same instance. That said if now another thread or even the same thread later will callAttributeMap.attr(AttributeKey)again, a newAttributeinstance is created and so is not the same as the previous one that was removed. Because of this special caution should be taken when you callAttribute.remove()orAttribute.getAndRemove().
-
remove0
private void remove0()
-
-