added getThreads() function

This commit is contained in:
hns 2001-01-31 19:14:24 +00:00
parent da000151d0
commit 5ada1c1876

View file

@ -23,6 +23,7 @@ public class ESAppNode extends ESNode {
app = eval.app;
createtime = new DatePrototype (eval.evaluator, node.created());
FunctionPrototype fp = (FunctionPrototype) eval.evaluator.getFunctionPrototype();
putHiddenProperty("getThreads", new AppCountThreads ("getThreads", evaluator, fp));
putHiddenProperty("getMaxThreads", new AppCountEvaluators ("getMaxThreads", evaluator, fp));
putHiddenProperty("getFreeThreads", new AppCountFreeEvaluators ("getFreeThreads", evaluator, fp));
putHiddenProperty("getActiveThreads", new AppCountBusyEvaluators ("getActiveThreads", evaluator, fp));
@ -89,6 +90,15 @@ public class ESAppNode extends ESNode {
}
}
class AppCountThreads extends BuiltinFunctionObject {
AppCountThreads (String name, Evaluator evaluator, FunctionPrototype fp) {
super (fp, evaluator, name, 0);
}
public ESValue callFunction (ESObject thisObject, ESValue[] arguments) throws EcmaScriptException {
return new ESNumber (app.threadgroup.activeCount() -1);
}
}
class AppSetNumberOfEvaluators extends BuiltinFunctionObject {
AppSetNumberOfEvaluators (String name, Evaluator evaluator, FunctionPrototype fp) {
super (fp, evaluator, name, 1);