This was intended to suggest that you use lazy generators rather than using greedy collections as the concurrent evaluation system I had in place could take advantage of that to automatically multithread your code. I've changed the implementation of mustache.java around somewhat since then as aggressive concurrent evaluation was detrimental to performance when it was unnecessary but you can still take advantage of concurrent evaluation with the right backing code.
If you want to evaluate something concurrently with the rest of the evaluation of the template but still want it to come out in the order of the template instead of returning the actual value from the field or method, return a Callable. You can see some tests of this behavior in InterpreterTest. Right now you do need to explicitly close the writer returned from execute to get the right blocking behavior, so be careful with that.
In terms of BigPipe-style handling, I should really release a small example framework where it is used. The general idea is that you return a referenceable div, then asynchronously begin work and add a Future to a list to be evaluated at the end of the body that will transform results into javascript insertions.
protected void writeTarget(Writer writer, Long divid) throws IOException {
// append nothing.
}
protected static void writeDeferral(StringBuilder sb, Deferral deferral, Object o) {
sb.append(o.toString().replace("<", "<").replace("\"", "\\\"").replace("\n", "\\n"));
}
Sam
Sam