Package net.algart.contexts
Class DefaultArrayContext
java.lang.Object
net.algart.arrays.AbstractArrayContext
net.algart.contexts.DefaultArrayContext
- All Implemented Interfaces:
ArrayContext
A simple implementation of ArrayContext
interface,
based on the memory
,
thread pool
,
interruption
and
progress
contexts defined in this package.
- Author:
- Daniel Alievsky
-
Nested Class Summary
Nested classes/interfaces inherited from interface net.algart.arrays.ArrayContext
ArrayContext.Event
-
Field Summary
Fields inherited from interface net.algart.arrays.ArrayContext
DEFAULT, DEFAULT_SINGLE_THREAD
-
Constructor Summary
ConstructorDescriptionDefaultArrayContext
(Context context) Creates new instance of this class, based on the passed context.DefaultArrayContext
(Context context, ThreadPoolFactory threadPoolFactory) Creates new instance of this class, based on the passed context, which returns the specified threadPoolFactory bygetThreadPoolFactory()
method. -
Method Summary
Modifier and TypeMethodDescriptionvoid
Calls context.as
(InterruptionContext
.class).checkInterruption()
, where context is the argument of the construcor.Returns the result of context.as
(ArrayMemoryContext
.class).getMemoryModel()
call, where context is the argument of the construcor.Returns the result of context.as
(ArrayThreadPoolContext
.class).getThreadPoolFactory()
call, where context is the argument of the construcor, or threadPoolFactory constructor argument, if this instance was created withthe corresponding variant of the constructor
.toString()
void
updateProgress
(ArrayContext.Event event) Calls context.as
(ProgressUpdater
.class).updateProgress
(part, part==1.0), where context is the argument of the construcor and part=event.readyPart()
.Methods inherited from class net.algart.arrays.AbstractArrayContext
checkInterruptionAndUpdateProgress, currentThreadIndex, customData, customDataVersion, multithreadingVersion, noProgressVersion, numberOfThreads, part, part, singleThreadVersion
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface net.algart.arrays.ArrayContext
checkInterruptionAndUpdateProgress, currentThreadIndex, customData, customDataVersion, multithreadingVersion, noProgressVersion, numberOfThreads, part, part, singleThreadVersion
-
Constructor Details
-
DefaultArrayContext
Creates new instance of this class, based on the passed context. The passed context mustallow to get
the following specific contexts:ArrayMemoryContext
,ArrayThreadPoolContext
,InterruptionContext
andProgressUpdater
.- Parameters:
context
- the context that will be used by methods of this class.- Throws:
NullPointerException
- if the argument is null.UnsupportedContextException
- if this context cannot serve at least one from the requested 4 specified contexts.
-
DefaultArrayContext
Creates new instance of this class, based on the passed context, which returns the specified threadPoolFactory bygetThreadPoolFactory()
method. The passed context mustallow to get
the following specific contexts:ArrayMemoryContext
,InterruptionContext
andProgressUpdater
. This constructor can be used, for example, if you need to clarify the desired number of parallel threads (usually set it to 1) byDefaultThreadPoolFactory.getDefaultThreadPoolFactory(int)
method.- Parameters:
context
- the context that will be used by methods of this class.threadPoolFactory
- the thread pool factory that will be used by this object.- Throws:
NullPointerException
- if the context or threadPoolFactory argument is null.UnsupportedContextException
- if this context cannot serve at least one from the requested 3 specified contexts.
-
-
Method Details
-
getMemoryModel
Returns the result of context.as
(ArrayMemoryContext
.class).getMemoryModel()
call, where context is the argument of the construcor.- Specified by:
getMemoryModel
in interfaceArrayContext
- Specified by:
getMemoryModel
in classAbstractArrayContext
- Returns:
- the desired thread pool factory.
-
getThreadPoolFactory
Returns the result of context.as
(ArrayThreadPoolContext
.class).getThreadPoolFactory()
call, where context is the argument of the construcor, or threadPoolFactory constructor argument, if this instance was created withthe corresponding variant of the constructor
.- Specified by:
getThreadPoolFactory
in interfaceArrayContext
- Specified by:
getThreadPoolFactory
in classAbstractArrayContext
- Returns:
- the desired thread pool factory.
-
checkInterruption
Calls context.as
(InterruptionContext
.class).checkInterruption()
, where context is the argument of the construcor.- Specified by:
checkInterruption
in interfaceArrayContext
- Specified by:
checkInterruption
in classAbstractArrayContext
- Throws:
RuntimeException
- if the application has requested to interrupt the currently executing module; in this implementation, it will be alwaysInterruptionException
instance.
-
updateProgress
Calls context.as
(ProgressUpdater
.class).updateProgress
(part, part==1.0), where context is the argument of the construcor and part=event.readyPart()
.- Specified by:
updateProgress
in interfaceArrayContext
- Specified by:
updateProgress
in classAbstractArrayContext
- Parameters:
event
- information about the execution progress.
-
toString
-