lundi 15 juin 2015

Delay in compiling code using "scala.tools.reflect ToolBox" When I Create a single toolbox instance for the whole application

What is the best way to create toolbox instance ? scala.reflect.runtime.universe.runtimeMirror(getClass.getClassLoader).mkToolBox()

Is it good to create once for the whole app? - Having one instance in the object and make use of it? Or Create a toolBox instance for each parse and eval (Create mkToolBox() )

I'm facing huge delay while its compiling the class where there is a single instance of ToolBox used for the whole app. I'm seeing better results when I create the ToolBox instance each time for each parse and eval

I would like to know if anybody faced similar kind of issue! Since I'm not sure about the internals of it, Dropping this message for the experts to comment.

Note : I'm dynamically building FSMs classes using that.

Sample code:

object X{
private val tb = scala.reflect.runtime.universe.runtimeMirror(getClass.getClassLoader).mkToolBox()
}
class Template{
  val tree = tb.parse(ruleTemplate)
  val y = tb.eval(tree)
}

Appreciate your help and thanks in advance!





Aucun commentaire:

Enregistrer un commentaire