com.kccoder.fracture
Class Fracture

java.lang.Object
  extended by com.kccoder.fracture.Fracture

public class Fracture
extends java.lang.Object

This is the core class in the Fracture library. Here you can set/get the 'Core Mode' and execute multi-core loops either synchronously or asynchronously.

This software is distributed WITHOUT ANY WARRANTY, without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.

Author:
Cameron Shelton (http://kccoder.com)

Constructor Summary
Fracture()
           
 
Method Summary
static void forEach(int start, int end, int increment, IProcessor<java.lang.Integer> processor)
          Essentially equivalent to for(int i = start; i < end; i+=increment) executed on N cores.
static
<T> void
forEach(java.lang.Iterable<T> iterable, IProcessor<T> processor)
          Process each element present in the iterable's iterator on N cores.
static
<T> void
forEach(java.util.Iterator<T> iterator, IProcessor<T> processor)
          Process each element present in the iterator on N cores.
static
<T> void
forEach(T[] elements, IProcessor<T> processor)
          Process each array element on N cores.
static void forEachSync(int start, int end, int increment, IProcessor<java.lang.Integer> processor)
          Essentially equivalent to for(int i = start; i < end; i+=increment) executed on N cores.
static
<T> void
forEachSync(java.lang.Iterable<T> iterable, IProcessor<T> processor)
          Process each element present in the iterable's iterator on N cores.
static
<T> void
forEachSync(java.util.Iterator<T> iterator, IProcessor<T> processor)
          Process each element present in the iterator on N cores.
static
<T> void
forEachSync(T[] elements, IProcessor<T> processor)
          Process each array element on N cores.
static CoreMode getCoreMode()
          Get the currently configured CoreMode.
static void setCoreMode(CoreMode coreMode)
          Confiure the Fracture library CoreMode.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Fracture

public Fracture()
Method Detail

getCoreMode

public static CoreMode getCoreMode()
Get the currently configured CoreMode.

Returns:
The currently configured CoreMode

setCoreMode

public static void setCoreMode(CoreMode coreMode)
Confiure the Fracture library CoreMode.

Parameters:
coreMode - - the desired CoreMode

forEach

public static <T> void forEach(T[] elements,
                               IProcessor<T> processor)
Process each array element on N cores.

Type Parameters:
T - Element type
Parameters:
elements - Element array
processor - Processor to process each element

forEach

public static <T> void forEach(java.lang.Iterable<T> iterable,
                               IProcessor<T> processor)
Process each element present in the iterable's iterator on N cores.

Type Parameters:
T - Element type
Parameters:
iterable - Elements to be processed
processor - Processor to process each element

forEach

public static <T> void forEach(java.util.Iterator<T> iterator,
                               IProcessor<T> processor)
Process each element present in the iterator on N cores.

Type Parameters:
T - Element type
Parameters:
iterator - Elements to be processed
processor - Processor to process each element

forEach

public static void forEach(int start,
                           int end,
                           int increment,
                           IProcessor<java.lang.Integer> processor)
Essentially equivalent to for(int i = start; i < end; i+=increment) executed on N cores.

Parameters:
start - Starting value
end - Ending value
increment - Increment value
processor - Processor to process each integer

forEachSync

public static <T> void forEachSync(T[] elements,
                                   IProcessor<T> processor)
Process each array element on N cores. This method executes this process in the bacground and then returns.

Type Parameters:
T - Element type
Parameters:
elements - Element array
processor - Processor to process each element

forEachSync

public static <T> void forEachSync(java.lang.Iterable<T> iterable,
                                   IProcessor<T> processor)
Process each element present in the iterable's iterator on N cores. This method executes this process in the bacground and then returns.

Type Parameters:
T - Element type
Parameters:
iterable - Elements to be processed
processor - Processor to process each element

forEachSync

public static <T> void forEachSync(java.util.Iterator<T> iterator,
                                   IProcessor<T> processor)
Process each element present in the iterator on N cores. This method executes this process in the bacground and then returns.

Type Parameters:
T - Element type
Parameters:
iterator - Elements to be processed
processor - Processor to process each element

forEachSync

public static void forEachSync(int start,
                               int end,
                               int increment,
                               IProcessor<java.lang.Integer> processor)
Essentially equivalent to for(int i = start; i < end; i+=increment) executed on N cores. This method executes this process in the bacground and then returns.

Parameters:
start - Starting value
end - Ending value
increment - Increment value
processor - Processor to process each integer