All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.openl.util.ce.impl.ServiceST Maven / Gradle / Ivy

There is a newer version: 5.19.9
Show newest version
package org.openl.util.ce.impl;

import java.lang.reflect.Array;
import java.util.concurrent.Callable;

import org.openl.util.IConvertor;
import org.openl.util.ce.ArrayExecutionException;
import org.openl.util.ce.IMTConvertorFactory;
import org.openl.util.ce.IScheduler;
import org.openl.util.ce.conf.ServiceMTConfiguration;

/**
 * 
 * Single-threaded implementation of the service. 
 * Should be used in the circumstances when multi-threading is
 * not useful, not needed or even non-desirable.
 * 
 *   
  • multi-threading is not useful when there is none or little multi-core CPU power available * to the application. This could be the case on single or double-core CPUs and other special cases * *
  • multi-threading is not needed, for example, when you run benchmarks and profile linear code performance * *
  • sometimes multi-threading must be turned off when you run into race conditions or other problems * that can not be explained from the single-treaded point of view. While we will make sure that OpenL code and * the code of the libraries that we use pass the most rigorous testing, before releasing it, there is always * a chance that some things remain unaccounted for, especially in MT, where there is no clear definition of the test * coverage. And, my friends, there is always your code that may interact with MT in some unexpected ways. * * * @author snshor * */ public class ServiceST extends ServiceBase { public ServiceST(ServiceMTConfiguration config) { super(config); } @Override public long executeAll(Callable[] calls, T[] result, long duration) throws ArrayExecutionException { return executeAllSequential(calls, result, 0, result.length); } @Override public long executeArray(IConvertor conv, A[] inputArray, T[] result, long duration) throws ArrayExecutionException { return executeArraySequential(conv, inputArray, result, 0, result.length); } @Override public long executeIndexed(IConvertor conv, T[] result, long durationEstimate) throws ArrayExecutionException { long time = executeIndexedSequential(conv, result, 0, result.length); return time; } @Override public long executeIndexedPrimitive(IConvertor conv, Object results, long durationEstimate) throws ArrayExecutionException { return executeIndexedSequentialPrimitive(conv, results, 0, Array.getLength(results)); } @Override public long executeIndexed(IMTConvertorFactory factory, T[] result) throws ArrayExecutionException { return executeIndexedSequential(factory.makeConvertorInstance(), result, 0, result.length); } @Override public void shutdown() { // nothing to do } @Override public long executeAll(Runnable[] tasks) throws ArrayExecutionException { return executeAllSequential(tasks, 0, tasks.length); } @Override public IScheduler getScheduler(long singleCellLength) { return new Scheduler(config, singleCellLength); } @Override public int getActiveThreadCounter() { return 0; } }




  • © 2015 - 2025 Weber Informatics LLC | Privacy Policy