org.mozilla.javascript.Context.observeInstructionCount()方法的使用及代码示例

x33g5p2x  于2022-01-18 转载在 JavaScript  
字(4.0k)|赞(0)|评价(0)|浏览(161)

本文整理了Java中org.mozilla.javascript.Context.observeInstructionCount()方法的一些代码示例,展示了Context.observeInstructionCount()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Context.observeInstructionCount()方法的具体详情如下:
包路径:org.mozilla.javascript.Context
类名称:Context
方法名:observeInstructionCount

Context.observeInstructionCount介绍

[英]Allow application to monitor counter of executed script instructions in Context subclasses. Run-time calls this when instruction counting is enabled and the counter reaches limit set by setInstructionObserverThreshold(). The method is useful to observe long running scripts and if necessary to terminate them.

The default implementation calls ContextFactory#observeInstructionCount(Context cx,int instructionCount)that allows to customize Context behavior without introducing Context subclasses.
[中]允许应用程序监视上下文子类中已执行脚本指令的计数器。当指令计数启用且计数器达到setInstructionObserverThreshold()设置的限制时,运行时调用此函数。该方法对于观察长时间运行的脚本以及在必要时终止脚本非常有用。
默认实现调用ContextFactory#observeInstructionCount(Context cx,int-instructionCount),允许自定义上下文行为而不引入上下文子类。

代码示例

代码示例来源:origin: rhino/js

private static void addInstructionCount(Context cx, CallFrame frame,
                      int extra)
  {
    cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
    if (cx.instructionCount > cx.instructionThreshold) {
      cx.observeInstructionCount(cx.instructionCount);
      cx.instructionCount = 0;
    }
  }
}

代码示例来源:origin: ro.isdc.wro4j/rhino

public static void addInstructionCount(Context cx, int instructionsToAdd)
{
  cx.instructionCount += instructionsToAdd;
  if (cx.instructionCount > cx.instructionThreshold)
  {
    cx.observeInstructionCount(cx.instructionCount);
    cx.instructionCount = 0;
  }
}

代码示例来源:origin: com.github.tntim96/rhino

public static void addInstructionCount(Context cx, int instructionsToAdd)
{
  cx.instructionCount += instructionsToAdd;
  if (cx.instructionCount > cx.instructionThreshold)
  {
    cx.observeInstructionCount(cx.instructionCount);
    cx.instructionCount = 0;
  }
}

代码示例来源:origin: rhino/js

public static void addInstructionCount(Context cx, int instructionsToAdd)
{
  cx.instructionCount += instructionsToAdd;
  if (cx.instructionCount > cx.instructionThreshold) 
  {
    cx.observeInstructionCount(cx.instructionCount);
    cx.instructionCount = 0;
  }
}

代码示例来源:origin: geogebra/geogebra

private static void addInstructionCount(Context cx, CallFrame frame,
                      int extra)
  {
    cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
    if (cx.instructionCount > cx.instructionThreshold) {
      cx.observeInstructionCount(cx.instructionCount);
      cx.instructionCount = 0;
    }
  }
}

代码示例来源:origin: geogebra/geogebra

public static void addInstructionCount(Context cx, int instructionsToAdd)
{
  cx.instructionCount += instructionsToAdd;
  if (cx.instructionCount > cx.instructionThreshold)
  {
    cx.observeInstructionCount(cx.instructionCount);
    cx.instructionCount = 0;
  }
}

代码示例来源:origin: io.apigee/rhino

public static void addInstructionCount(Context cx, int instructionsToAdd)
{
  cx.instructionCount += instructionsToAdd;
  if (cx.instructionCount > cx.instructionThreshold)
  {
    cx.observeInstructionCount(cx.instructionCount);
    cx.instructionCount = 0;
  }
}

代码示例来源:origin: io.apigee/rhino

private static void addInstructionCount(Context cx, CallFrame frame,
                      int extra)
  {
    cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
    if (cx.instructionCount > cx.instructionThreshold) {
      cx.observeInstructionCount(cx.instructionCount);
      cx.instructionCount = 0;
    }
  }
}

代码示例来源:origin: com.sun.phobos/phobos-rhino

private static void addInstructionCount(Context cx, CallFrame frame,
                      int extra)
  {
    cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
    if (cx.instructionCount > cx.instructionThreshold) {
      cx.observeInstructionCount(cx.instructionCount);
      cx.instructionCount = 0;
    }
  }
}

代码示例来源:origin: ro.isdc.wro4j/rhino

private static void addInstructionCount(Context cx, CallFrame frame,
                      int extra)
  {
    cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
    if (cx.instructionCount > cx.instructionThreshold) {
      cx.observeInstructionCount(cx.instructionCount);
      cx.instructionCount = 0;
    }
  }
}

代码示例来源:origin: com.github.tntim96/rhino

private static void addInstructionCount(Context cx, CallFrame frame,
                      int extra)
  {
    cx.instructionCount += frame.pc - frame.pcPrevBranch + extra;
    if (cx.instructionCount > cx.instructionThreshold) {
      cx.observeInstructionCount(cx.instructionCount);
      cx.instructionCount = 0;
    }
  }
}

相关文章

微信公众号

Context类方法