-
-
Save christianwimmer/56f17b2d4658982f276501ac28617074 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static ByteBuffer plotAsSVGInNewIsolate(String function, double xmin, double xmax) { | |
/* Create a new isolate for the function evaluation and rendering. */ | |
IsolateThread renderingContext = Isolates.createIsolate(CreateIsolateParameters.getDefault()); | |
IsolateThread nettyContext = CurrentIsolate.getCurrentThread(); | |
/* Copy the function String from the Netty isolate into the rendering isolate. */ | |
ObjectHandle functionHandle = copyString(renderingContext, function); | |
/* Render the function. This call performs the transition from the Netty isolate to the rendering isolate, triggered by the annotations of plotAsSVG. */ | |
ObjectHandle resultHandle = plotAsSVG(renderingContext, nettyContext, functionHandle, xmin, xmax); | |
/* Resolve and delete the resultHandle, now that execution is back in the Netty isolate. */ | |
ByteBuffer result = ObjectHandles.getGlobal().get(resultHandle); | |
ObjectHandles.getGlobal().destroy(resultHandle); | |
/* Tear down the isolate, freeing all the temporary objects. */ | |
Isolates.tearDownIsolate(renderingContext); | |
return result; | |
} | |
@CEntryPoint | |
private static ObjectHandle plotAsSVG(@CEntryPoint.IsolateThreadContext IsolateThread renderingContext, IsolateThread nettyContext, ObjectHandle functionHandle, double xmin, double xmax) { | |
/* Resolve and delete the functionHandle, now that execution is in the rendering isolate. */ | |
String function = ObjectHandles.getGlobal().get(functionHandle); | |
ObjectHandles.getGlobal().destroy(functionHandle); | |
... | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment