org.multiverse.transactional.nonblocking
Class DefaultTransactionSelector<K extends TransactionSelectionKey>

java.lang.Object
  extended by org.multiverse.transactional.nonblocking.DefaultTransactionSelector<K>
Type Parameters:
K -
All Implemented Interfaces:
TransactionSelector<K>

public class DefaultTransactionSelector<K extends TransactionSelectionKey>
extends java.lang.Object
implements TransactionSelector<K>

The default TransactionSelector implementation.

Author:
Peter Veentjer.

Constructor Summary
DefaultTransactionSelector()
          Creates a new DefaultTransactionSelector with a LinkedBlockingQueue is arrivedTasks queue implementation.
DefaultTransactionSelector(java.util.concurrent.BlockingQueue<K> arrivedTasks)
          Creates a new TransactionSelector with the provided pending task queue.
 
Method Summary
 void close()
           
 void register(K task)
          Registers a NonBlockingTaskContext to this TransactionSelector so that it

No guarantees are made of the same NonBlockingTaskContext is registered while it already is registered (and not been returned with a select).

 K select()
          Selects a NonBlockingTaskContext ready for execution or wait until a task comes available.
 K selectNow()
          Selects a key to use or null if none available.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

DefaultTransactionSelector

public DefaultTransactionSelector()
Creates a new DefaultTransactionSelector with a LinkedBlockingQueue is arrivedTasks queue implementation.


DefaultTransactionSelector

public DefaultTransactionSelector(java.util.concurrent.BlockingQueue<K> arrivedTasks)
Creates a new TransactionSelector with the provided pending task queue.

Parameters:
arrivedTasks - the BlockingQueue where the Trans
Throws:
java.lang.NullPointerException - if arrivedTasks is null.
Method Detail

register

public void register(K task)
Description copied from interface: TransactionSelector
Registers a NonBlockingTaskContext to this TransactionSelector so that it

No guarantees are made of the same NonBlockingTaskContext is registered while it already is registered (and not been returned with a select).

Specified by:
register in interface TransactionSelector<K extends TransactionSelectionKey>

select

public K select()
                                         throws java.lang.InterruptedException
Description copied from interface: TransactionSelector
Selects a NonBlockingTaskContext ready for execution or wait until a task comes available.

Once the NonBlockingTaskContext is returned, it needs to be registered again if it wants to participate in another attempt.

Specified by:
select in interface TransactionSelector<K extends TransactionSelectionKey>
Returns:
the NonBlockingTask that is ready for execution.
Throws:
java.lang.InterruptedException - if the thread is interrupted while waiting for a task to come available.

selectNow

public K selectNow()
Description copied from interface: TransactionSelector
Selects a key to use or null if none available.

Specified by:
selectNow in interface TransactionSelector<K extends TransactionSelectionKey>
Returns:
the selected key, or null if none available.

close

public void close()
Specified by:
close in interface TransactionSelector<K extends TransactionSelectionKey>


Copyright © 2008-2010 Multiverse. All Rights Reserved.