Class UpdatableIterator<E>
- java.lang.Object
-
- org.apache.activemq.artemis.utils.collections.UpdatableIterator<E>
-
- All Implemented Interfaces:
Iterator<E>,RepeatableIterator<E>,ResettableIterator<E>
public class UpdatableIterator<E> extends Object implements ResettableIterator<E>, RepeatableIterator<E>
-
-
Constructor Summary
Constructors Constructor Description UpdatableIterator(ResettableIterator<E> iterator)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidforEachRemaining(Consumer<? super E> action)booleanhasNext()Enext()voidremove()voidrepeat()If the current value should repeat.voidreset()When reset is called, then if a new iterator has been provided by another thread via update method, then we switch over to using the new iterator.voidupdate(ResettableIterator<E> iterator)This can be called by another thread.
-
-
-
Constructor Detail
-
UpdatableIterator
public UpdatableIterator(ResettableIterator<E> iterator)
-
-
Method Detail
-
update
public void update(ResettableIterator<E> iterator)
This can be called by another thread. It sets a new iterator, that will be picked up on the next reset.- Parameters:
iterator- the new iterator to update to.
-
reset
public void reset()
When reset is called, then if a new iterator has been provided by another thread via update method, then we switch over to using the new iterator. It is important that on nulling off the changedIterator, we atomically compare and set as the changedIterator could be further updated by another thread whilst we are resetting, the subsequent update simply would be picked up on the next reset.- Specified by:
resetin interfaceResettableIterator<E>
-
forEachRemaining
public void forEachRemaining(Consumer<? super E> action)
- Specified by:
forEachRemainingin interfaceIterator<E>
-
repeat
public void repeat()
Description copied from interface:RepeatableIteratorIf the current value should repeat.- Specified by:
repeatin interfaceRepeatableIterator<E>
-
-