Is dcbFreeCallback safe when a registered callback function is running?

I am using the Java OpenCL binding provided by lwjgl 3.

When I call clSetEventCallback, I need to pass a callback function clSetEventCallback. For each call, clSetEventCallbackI created a new callback function from lwjgl CLEventCallback.create, which eventually calls dyncall dcbNewCallback().

CLEventCallback myCallback = CLEventCallback.create(new CLEventCallbackI {
  ...
});
clSetEventCallback(..., myCallback, ...);

Since the callback function passed to clSetEventCallbackwill be evaluated once and only once, I want to destroy it when it is called by OpenCL.

@Override
public void invoke(long event, int status, long user_data) {
  myCallback.close();
}

myCallback.close()provided by lwjgl and eventually it will call dyncall dcbFreeCallback().

The above code is suitable for me.

I think if it dyncallcreates JMP-like instructions for all processors, then this is safe.

dyncall, dcbFreeCallback(), .

, ?

+6

Source: https://habr.com/ru/post/1015902/


All Articles