Skip to content
Snippets Groups Projects
Commit 725a15eb authored by Mick Jordan's avatar Mick Jordan
Browse files

add par arg to fastr_context.eval

parent 20cffc1f
No related branches found
No related tags found
No related merge requests found
......@@ -14,4 +14,5 @@ export(fastr.createpkgsources)
export(fastr.createpkgsource)
export(fastr_context.create)
export(fastr_context.eval)
export(fastr_context.pareval)
export(print.fastr_context)
......@@ -82,10 +82,14 @@ print.fastr_context <- function(context, ...) {
invisible(context)
}
fastr_context.eval <- function(context, expr) {
.FastR(.NAME="context.eval", context, expr)
fastr_context.eval <- function(contexts, exprs, par=FALSE) {
.FastR(.NAME="context.eval", contexts, exprs, par)
invisible(NULL)
}
fastr_context.pareval <- function(contexts, exprs) {
fastr_context.eval(contexts, exprs, par=TRUE)
}
......@@ -53,20 +53,12 @@ public class FastRContext {
}
}
static void eval(RIntVector contexts, RStringVector exprs) {
if (contexts.getLength() == 1) {
RContext context = checkContext(contexts.getDataAt(0));
try {
context.activate();
context.getThisEngine().parseAndEval(Source.fromText(exprs.getDataAt(0), "<eval_input>"), true, false);
} finally {
context.destroy();
}
} else {
static void eval(RIntVector contexts, RStringVector exprs, boolean par) {
if (par) {
RContext.EvalThread[] threads = new RContext.EvalThread[contexts.getLength()];
for (int i = 0; i < threads.length; i++) {
RContext context = checkContext(contexts.getDataAt(i));
threads[i] = new RContext.EvalThread(context, Source.fromText(exprs.getDataAt(i % threads.length), "context_eval"));
threads[i] = new RContext.EvalThread(context, Source.fromText(exprs.getDataAt(i % threads.length), "<context_eval>"));
}
for (int i = 0; i < threads.length; i++) {
threads[i].start();
......@@ -78,6 +70,16 @@ public class FastRContext {
} catch (InterruptedException ex) {
}
} else {
for (int i = 0; i < contexts.getLength(); i++) {
RContext context = checkContext(contexts.getDataAt(i));
try {
context.activate();
context.getThisEngine().parseAndEval(Source.fromText(exprs.getDataAt(i), "<context_eval>"), true, false);
} finally {
context.destroy();
}
}
}
}
......
......@@ -73,7 +73,7 @@ public class FastRFunctionEntry {
return RNull.instance;
case "context.eval":
FastRContext.eval((RIntVector) RRuntime.asAbstractVector(arg0), (RStringVector) RRuntime.asAbstractVector(argValues[1]));
FastRContext.eval((RIntVector) RRuntime.asAbstractVector(arg0), (RStringVector) RRuntime.asAbstractVector(argValues[1]), RRuntime.fromLogical(checkLogical(argValues[2], fastRNode)));
return RNull.instance;
default:
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment