Class BlockingList<T>
- java.lang.Object
-
- com.sportradar.livedata.sdk.common.classes.BlockingList<T>
-
public class BlockingList<T> extends Object
A list whose {code compareAndRemove} methods block until the specified item is removed.
-
-
Constructor Summary
Constructors Constructor Description BlockingList()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
add(T item)
Adds the passed instance to the list.void
compareAndRemove(T item, long timeout)
Blocks until the searched item is found and removed from the list.void
compareAndRemove(T item, Comparator<T> comparator, long timeout)
Blocks until the searched item is found and removed from the list.boolean
isEmpty()
Returns true if this list contains no elements.int
size()
Returns the number of elements in this list.
-
-
-
Method Detail
-
size
public int size()
Returns the number of elements in this list. If this list contains more than Integer.MAX_VALUE elements, returns Integer.MAX_VALUE.- Returns:
- the number of elements in this list.
-
isEmpty
public boolean isEmpty()
Returns true if this list contains no elements.- Returns:
- true if this list contains no elements.
-
add
public void add(T item)
Adds the passed instance to the list.- Parameters:
item
- the item to be added to the list.
-
compareAndRemove
public void compareAndRemove(T item, long timeout) throws InterruptedException
Blocks until the searched item is found and removed from the list.- Parameters:
item
- The item which is to be removed from the list or null to remove the first item.timeout
- The time in milliseconds to wait for the item.- Throws:
InterruptedException
- item was not found in the list in the time allowed time window.
-
compareAndRemove
public void compareAndRemove(T item, Comparator<T> comparator, long timeout) throws InterruptedException
Blocks until the searched item is found and removed from the list.- Parameters:
item
- The item which is to be removed from the list or null to remove the first item.comparator
- theComparator
used to compare the stored items to the passed one.timeout
- The time in milliseconds to wait for the item.- Throws:
InterruptedException
- item was not found in the list in the time allowed time window.
-
-