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
ConstructorsConstructorDescriptionDefaultArrayContext(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 TypeMethodDescriptionvoidCalls 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()voidupdateProgress(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, singleThreadVersionMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods 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 getthe following specific contexts:ArrayMemoryContext,ArrayThreadPoolContext,InterruptionContextandProgressUpdater.- 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 getthe following specific contexts:ArrayMemoryContext,InterruptionContextandProgressUpdater. 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:
getMemoryModelin interfaceArrayContext- Specified by:
getMemoryModelin 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:
getThreadPoolFactoryin interfaceArrayContext- Specified by:
getThreadPoolFactoryin classAbstractArrayContext- Returns:
- the desired thread pool factory.
-
checkInterruption
Calls context.as(InterruptionContext.class).checkInterruption(), where context is the argument of the construcor.- Specified by:
checkInterruptionin interfaceArrayContext- Specified by:
checkInterruptionin classAbstractArrayContext- Throws:
RuntimeException- if the application has requested to interrupt the currently executing module; in this implementation, it will be alwaysInterruptionExceptioninstance.
-
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:
updateProgressin interfaceArrayContext- Specified by:
updateProgressin classAbstractArrayContext- Parameters:
event- information about the execution progress.
-
toString
-