Class ArrayContext.Event
- Enclosing interface:
ArrayContext
ArrayContext.updateProgress(Event)
method.-
Constructor Summary
ConstructorDescriptionCreates new event with the specifiedelementType()
,length()
,readyCount()
for the case of 1parallel task
. -
Method Summary
Modifier and TypeMethodDescriptionClass<?>
Returns the type of elements in the source AlgART array, passed to an array processing method alikeArrays.ParallelExecutor.process()
.long
length()
Returns the total number of processed elements.long[]
Returns the total number of elements, that must be processed per each of parallel tasks, which the algorithm is split into.int
Returns the number of parallel tasks, which the algorithm is split into.long
Returns the number of elements that was already processed until this moment.long[]
Returns the number of elements, that was already processed until this moment per each of parallel tasks, which the algorithm is split into.double
Returns the ready part of total algorithm execution.
-
Constructor Details
-
Event
Creates new event with the specifiedelementType()
,length()
,readyCount()
for the case of 1parallel task
. ThereadyPart()
method in the created instance returns (double)readyCount/(double)length. Equivalent to new Event(elementType, new long[] {length}, new long[] {readyCount}).- Parameters:
elementType
- the result ofelementType()
method in the created event; may be null.readyCount
- the only element in the result ofreadyCountPerTask()
method in the created event.length
- the result oflength()
method in the created event.- Throws:
IllegalArgumentException
- if length or readyCount is negative, or if readyCount>length.
-
Event
Creates new event with the specifiedelementType()
,lengthPerTask()
andreadyCountPerTask()
. Thelength()
method in the created instance returns the sum of all elements of lengthPerTask argument. ThereadyCount()
method returns the sum of all elements of readyCountPerTask argument. ThenumberOfParallelTasks()
method returns the length of each of the passed arrays (their lengths must be equal). ThereadyPart()
method returns (double)readyCount()
/(double)length()
.All elements of the readyCountPerTask array must not be greater than the corresponding elements of the lengthsPerTask array. All elements of these arrays must not be negative.
The passed lengthPerTask and readyCountPerTask arguments are cloned by this method: no references to them are maintained by the created instance.
- Parameters:
elementType
- the result ofelementType()
method in the created event; may be null.readyCountPerTask
- the result ofreadyCountPerTask()
method in the created event.lengthPerTask
- the result oflengthPerTask()
method in the created event.- Throws:
NullPointerException
- if lengthPerTask or readyCountPerTask is null.IllegalArgumentException
- if lengthPerTask or readyCountPerTask is an empty array, or if their lengths are not equal, or if some their elements are negative, or if readyCountPerTask[k] is than lengthPerTask[k] for some index k, or if the sum of all elements of one of these arrays is greater than Long.MAX_VALUE.
-
-
Method Details
-
elementType
Returns the type of elements in the source AlgART array, passed to an array processing method alikeArrays.ParallelExecutor.process()
. If the context of using cannot define a suitable type of array elements, this method may return null.- Returns:
- the type of elements in the source array.
- See Also:
-
lengthPerTask
public long[] lengthPerTask()Returns the total number of elements, that must be processed per each of parallel tasks, which the algorithm is split into. (So, the number of parallel tasks is equal to the length of the returned array.) These elements are usually located in several ranges in the array, some number of regions per one task.The returned array is a clone of the internal array stored in this object. The returned array is never empty (its length cannot be zero).
- Returns:
- the total number of elements, that must be processed per each of parallel tasks, which the algorithm is split into.
-
length
public long length()Returns the total number of processed elements. Always equal to the sum of all elements in the array, returned bylengthPerTask()
method.For
Arrays.copy(ArrayContext, UpdatableArray, Array)
method, returns min(dest.length()
, src.length()
), where dest and src are the AlgART arrays passed this method. ForArrays.ParallelExecutor.process()
method and another methods based on it, return src.Array.length()
, where src is the processed AlgART array.- Returns:
- the total number of processing elements.
-
readyCountPerTask
public long[] readyCountPerTask()Returns the number of elements, that was already processed until this moment per each of parallel tasks, which the algorithm is split into. (So, the number of parallel tasks is equal to the length of the returned array.) These elements are usually located in several ranges in the array, some number of regions per one task.The returned array is a clone of the internal array stored in this object. The returned array is never empty (its length cannot be zero).
- Returns:
- the number of elements, that was already processed until this moment per each of parallel tasks, which the algorithm is split into.
-
readyCount
public long readyCount()Returns the number of elements that was already processed until this moment. Always equal to the sum of all elements in the array, returned byreadyCountPerTask()
method.- Returns:
- the number of elements that was already processed until this moment.
-
numberOfParallelTasks
public int numberOfParallelTasks()Returns the number of parallel tasks, which the algorithm is split into. Always equal to the number of elements in the arrays, returned bylengthPerTask()
andreadyCountPerTask()
method.- Returns:
- the number of parallel tasks that are executed simultaneously in several threads.
- See Also:
-
readyPart
public double readyPart()Returns the ready part of total algorithm execution. In simple cases, returns (double)readyCount()
/(double)length()
. Returns 1.0 if and only if all calculations are finished. Also returns 1.0 iflength()
is zero.- Returns:
- the ready part of total algorithm execution (from 0.0 to 1.0).
- See Also:
-