org.multiverse.transactional.nonblocking
Interface TransactionSelector<K extends TransactionSelectionKey>

All Known Implementing Classes:
DefaultTransactionSelector

public interface TransactionSelector<K extends TransactionSelectionKey>

A TransactionSelector can be compared to the java.nio.channels.Selector. It makes it possible that multiple blocking transactions share the same executing thread. The advantage is that because no thread per blocking transaction is needed, the number of threads is reduced. In theory you could have millions of blocking transactions being executed by a few hundred threads. Of course the advantage of using this approach depends on the amount of blocking done.

Author:
Peter Veentjer.

Method Summary
 void close()
           
 void register(K key)
          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.
 

Method Detail

register

void register(K key)
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).

Parameters:
key -
Throws:
java.lang.NullPointerException - if key is null.

select

K select()
                                         throws java.lang.InterruptedException
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.

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

K selectNow()
Selects a key to use or null if none available.

Returns:
the selected key, or null if none available.

close

void close()


Copyright © 2008-2010 Multiverse. All Rights Reserved.