org.multiverse.transactional.collections
Class TransactionalLinkedList<E>
java.lang.Object
java.util.AbstractCollection<E>
org.multiverse.transactional.collections.AbstractBlockingDeque<E>
org.multiverse.transactional.collections.TransactionalLinkedList<E>
- Type Parameters:
E -
- All Implemented Interfaces:
- java.lang.Iterable<E>, java.util.Collection<E>, java.util.concurrent.BlockingDeque<E>, java.util.concurrent.BlockingQueue<E>, java.util.Deque<E>, java.util.List<E>, java.util.Queue<E>
public class TransactionalLinkedList<E>
- extends AbstractBlockingDeque<E>
- implements java.util.List<E>
A general purposes collection structure that could be considered a work horse because it implements a lot of
interfaces:
Iterable Collection List
Queue BlockingQueue Deque
BlockingDeque
Each operation on this TransactionalLinkedList is transactional by default, and of course can participate in already
running transactions.
There is a scalability issue with this structure and it has to do with unwanted writeconflicts. Although a take and
put can be executed concurrently because there is a seperate tail and head to place items on, one of the transactions
is going to fail because of a write conflict on the size field, or on the head/tail because of the object granularity
of the stm. This is an issue that is going to be solved in the future, but for the moment this structure will not be
very concurrent. This even gets worse with longer transactions that are typical for stm's, compared to classic
concurrency (the synchronized block could be seen as a transaction).
- Author:
- Peter Veentjer.
| Methods inherited from class org.multiverse.transactional.collections.AbstractBlockingDeque |
add, addAll, addFirst, addLast, drainTo, drainTo, element, getFirst, getLast, hasNoStorageCapacity, offer, offer, offerFirst, offerFirst, offerLast, offerLast, peek, poll, poll, pollFirst, pollFirst, pollLast, pollLast, pop, push, put, putFirst, putLast, remove, removeFirst, removeFirstOccurrence, removeLast, removeLastOccurrence, take, takeFirst, takeLast, takeUninterruptible |
| Methods inherited from class java.util.AbstractCollection |
contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray, toString |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Methods inherited from interface java.util.List |
add, addAll, contains, containsAll, isEmpty, removeAll, retainAll, toArray, toArray |
| Methods inherited from interface java.util.concurrent.BlockingDeque |
contains |
TransactionalLinkedList
public TransactionalLinkedList()
TransactionalLinkedList
public TransactionalLinkedList(int maxCapacity)
clear
public void clear()
- Specified by:
clear in interface java.util.Collection<E>- Specified by:
clear in interface java.util.List<E>- Overrides:
clear in class java.util.AbstractCollection<E>
getMaxCapacity
public int getMaxCapacity()
doAddLast
protected void doAddLast(E e)
- Specified by:
doAddLast in class AbstractBlockingDeque<E>
doAddFirst
protected void doAddFirst(E e)
- Specified by:
doAddFirst in class AbstractBlockingDeque<E>
doRemoveFirst
protected E doRemoveFirst()
- Specified by:
doRemoveFirst in class AbstractBlockingDeque<E>
doRemoveLast
protected E doRemoveLast()
- Specified by:
doRemoveLast in class AbstractBlockingDeque<E>
size
public int size()
- Specified by:
size in interface java.util.Collection<E>- Specified by:
size in interface java.util.concurrent.BlockingDeque<E>- Specified by:
size in interface java.util.Deque<E>- Specified by:
size in interface java.util.List<E>- Specified by:
size in class java.util.AbstractCollection<E>
iterator
public java.util.Iterator<E> iterator()
- Specified by:
iterator in interface java.lang.Iterable<E>- Specified by:
iterator in interface java.util.Collection<E>- Specified by:
iterator in interface java.util.concurrent.BlockingDeque<E>- Specified by:
iterator in interface java.util.Deque<E>- Specified by:
iterator in interface java.util.List<E>- Specified by:
iterator in class java.util.AbstractCollection<E>
remainingCapacity
public int remainingCapacity()
- Specified by:
remainingCapacity in interface java.util.concurrent.BlockingQueue<E>
peekFirst
public E peekFirst()
- Specified by:
peekFirst in interface java.util.Deque<E>
peekLast
public E peekLast()
- Specified by:
peekLast in interface java.util.Deque<E>
descendingIterator
public java.util.Iterator<E> descendingIterator()
- Specified by:
descendingIterator in interface java.util.Deque<E>
addAll
public boolean addAll(int index,
java.util.Collection<? extends E> c)
- Specified by:
addAll in interface java.util.List<E>
get
public E get(int index)
- Specified by:
get in interface java.util.List<E>
set
public E set(int index,
E element)
- Specified by:
set in interface java.util.List<E>
add
public void add(int index,
E element)
- Specified by:
add in interface java.util.List<E>
remove
public E remove(int index)
- Specified by:
remove in interface java.util.List<E>
indexOf
public int indexOf(java.lang.Object o)
- Specified by:
indexOf in interface java.util.List<E>
lastIndexOf
public int lastIndexOf(java.lang.Object o)
- Specified by:
lastIndexOf in interface java.util.List<E>
listIterator
public java.util.ListIterator<E> listIterator()
- Specified by:
listIterator in interface java.util.List<E>
listIterator
public java.util.ListIterator<E> listIterator(int index)
- Specified by:
listIterator in interface java.util.List<E>
subList
public java.util.List<E> subList(int fromIndex,
int toIndex)
- Specified by:
subList in interface java.util.List<E>
remove
public boolean remove(java.lang.Object item)
- Specified by:
remove in interface java.util.Collection<E>- Specified by:
remove in interface java.util.concurrent.BlockingDeque<E>- Specified by:
remove in interface java.util.concurrent.BlockingQueue<E>- Specified by:
remove in interface java.util.Deque<E>- Specified by:
remove in interface java.util.List<E>- Overrides:
remove in class java.util.AbstractCollection<E>
hashCode
public int hashCode()
- Specified by:
hashCode in interface java.util.Collection<E>- Specified by:
hashCode in interface java.util.List<E>- Overrides:
hashCode in class java.lang.Object
equals
public boolean equals(java.lang.Object thatObj)
- Specified by:
equals in interface java.util.Collection<E>- Specified by:
equals in interface java.util.List<E>- Overrides:
equals in class java.lang.Object
Copyright © 2008-2010 Multiverse. All Rights Reserved.