Skip to content

Commit

Permalink
Hide progress reporting behind Truffle boundary
Browse files Browse the repository at this point in the history
  • Loading branch information
JaroslavTulach committed Feb 25, 2025
1 parent f6156c5 commit a26bb2d
Showing 1 changed file with 16 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -100,23 +100,28 @@ public Object findCachedResult(IdExecutionService.Info info) {
return result;
} else {
if (onProgressCallbackOrNull != null) {
if (cache.getPreferences().get(nodeId) == CachePreferences.Kind.BINDING_EXPRESSION) {
var newObserver =
ExecutionProgressObserver.startComputation(
nodeId,
(progress) -> {
CompilerDirectives.transferToInterpreter();
var expressionValue = ExpressionValue.progress(nodeId, progress, null);
onProgressCallbackOrNull.accept(expressionValue);
});
refreshObserver(newObserver);
}
reportEvaluationProgress(nodeId);
}
}

return null;
}

@CompilerDirectives.TruffleBoundary
private void reportEvaluationProgress(UUID nodeId) {
if (cache.getPreferences().get(nodeId) == CachePreferences.Kind.BINDING_EXPRESSION) {
var newObserver =
ExecutionProgressObserver.startComputation(
nodeId,
(progress) -> {
CompilerDirectives.transferToInterpreter();
var expressionValue = ExpressionValue.progress(nodeId, progress, null);
onProgressCallbackOrNull.accept(expressionValue);
});
refreshObserver(newObserver);
}
}

private void refreshObserver(ExecutionProgressObserver newObserverOrNull) {
var o = progressObserver;
if (o != null) {
Expand Down

0 comments on commit a26bb2d

Please sign in to comment.