Skip to content

Commit

Permalink
Merge pull request #1167 from zspitzer/patch-28
Browse files Browse the repository at this point in the history
ignore parallel=true when limited to a single thread LDEV-2824
  • Loading branch information
michaeloffner authored Feb 9, 2024
2 parents c0986c8 + c51ab95 commit f9d90a2
Show file tree
Hide file tree
Showing 6 changed files with 12 additions and 13 deletions.
7 changes: 3 additions & 4 deletions core/src/main/java/lucee/runtime/functions/closure/Each.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public static String call(PageContext pc, Object obj, UDF udf, boolean parallel,
private static String _call(PageContext pc, Object obj, UDF udf, boolean parallel, int maxThreads, short type) throws PageException {
ExecutorService execute = null;
List<Future<Data<Object>>> futures = null;
if (parallel) {
if (parallel && maxThreads > 1) {
execute = Executors.newFixedThreadPool(maxThreads);
futures = new ArrayList<Future<Data<Object>>>();
}
Expand Down Expand Up @@ -138,8 +138,7 @@ else if (obj instanceof Enumeration) {
else if (obj instanceof StringListData) {
invoke(pc, (StringListData) obj, udf, execute, futures);
}

else throw new FunctionException(pc, "Each", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
else throw new FunctionException(pc, "Each", 1, "data", "Cannot iterate over this type [" + Caster.toTypeName(obj.getClass()) + "]");

if (parallel) afterCall(pc, futures, execute);

Expand Down Expand Up @@ -228,4 +227,4 @@ public Object invoke(PageContext pc, Object[] args) throws PageException {

}

}
}
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/functions/closure/Every.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static boolean _call(PageContext pc, Object obj, UDF udf, boolean parall

ExecutorService execute = null;
List<Future<Data<Object>>> futures = null;
if (parallel) {
if (parallel && maxThreads > 1) {
execute = Executors.newFixedThreadPool(maxThreads);
futures = new ArrayList<Future<Data<Object>>>();
}
Expand Down Expand Up @@ -131,7 +131,7 @@ else if (obj instanceof Enumeration) {
else if (obj instanceof StringListData) {
res = invoke(pc, (StringListData) obj, udf, execute, futures);
}
else throw new FunctionException(pc, "Every", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
else throw new FunctionException(pc, "Every", 1, "data", "Cannot iterate over this type [" + Caster.toTypeName(obj.getClass()) + "]");

if (parallel) res = afterCall(pc, futures, execute);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static Collection _call(PageContext pc, Object obj, UDF udf, boolean par

ExecutorService execute = null;
List<Future<Data<Pair<Object, Object>>>> futures = null;
if (parallel) {
if (parallel && maxThreads > 1) {
execute = Executors.newFixedThreadPool(maxThreads);
futures = new ArrayList<Future<Data<Pair<Object, Object>>>>();
}
Expand Down Expand Up @@ -135,7 +135,7 @@ else if (obj instanceof Enumeration) {
else if (obj instanceof StringListData) {
coll = invoke(pc, (StringListData) obj, udf, execute, futures);
}
else throw new FunctionException(pc, "Filter", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
else throw new FunctionException(pc, "Filter", 1, "data", "Cannot iterate over this type [" + Caster.toTypeName(obj.getClass()) + "]");

if (parallel) afterCall(pc, coll, futures, execute);

Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/functions/closure/Map.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ private static Collection _call(PageContext pc, Object obj, UDF udf, boolean par

ExecutorService execute = null;
List<Future<Data<Object>>> futures = null;
if (parallel) {
if (parallel && maxThreads > 1) {
execute = Executors.newFixedThreadPool(maxThreads);
futures = new ArrayList<Future<Data<Object>>>();
}
Expand Down Expand Up @@ -135,7 +135,7 @@ else if (obj instanceof Enumeration) {
else if (obj instanceof StringListData) {
coll = invoke(pc, (StringListData) obj, udf, execute, futures);
}
else throw new FunctionException(pc, "Map", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
else throw new FunctionException(pc, "Map", 1, "data", "Cannot iterate over this type [" + Caster.toTypeName(obj.getClass()) + "]");

if (parallel) afterCall(pc, coll, futures, execute);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ else if (obj instanceof Enumeration) {
else if (obj instanceof StringListData) {
value = invoke(pc, (StringListData) obj, udf, initalValue);
}
else throw new FunctionException(pc, "Filter", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
else throw new FunctionException(pc, "Filter", 1, "data", "Cannot iterate over this type [" + Caster.toTypeName(obj.getClass()) + "]");

return value;
}
Expand Down
4 changes: 2 additions & 2 deletions core/src/main/java/lucee/runtime/functions/closure/Some.java
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ private static boolean _call(PageContext pc, Object obj, UDF udf, boolean parall

ExecutorService execute = null;
List<Future<Data<Object>>> futures = null;
if (parallel) {
if (parallel && maxThreads > 1) {
execute = Executors.newFixedThreadPool(maxThreads);
futures = new ArrayList<Future<Data<Object>>>();
}
Expand Down Expand Up @@ -128,7 +128,7 @@ else if (obj instanceof Enumeration) {
else if (obj instanceof StringListData) {
res = invoke(pc, (StringListData) obj, udf, execute, futures);
}
else throw new FunctionException(pc, "Some", 1, "data", "cannot iterate througth this type " + Caster.toTypeName(obj.getClass()));
else throw new FunctionException(pc, "Some", 1, "data", "Cannot iterate over this type [" + Caster.toTypeName(obj.getClass()) + "]");

if (parallel) res = afterCall(pc, futures, execute);

Expand Down

0 comments on commit f9d90a2

Please sign in to comment.