Is there any way to pass a callback to java code, from C. And the call returns immediately. Later on, after completing the task, the java code can invoke that callback.
I have a C extension for php that calls a java store to store some items in it. The items can be retrieved from store in synchronous and asynchronous methods (I provide the store with list of keys and a callback and it invoke the callback and return the item in it).
I am able to retrieve the items synchronously from extension, but now I don't know how to do it asynchronously.
- Is there any way that my C code can give a pointer to function that java can later invoke?
- OR is it possible that I create a java thread everytime C code asks to retrieve items asynchronously, and that java thread then invoke a C function that can return the items back to user?
As a last resort I may have to create a thread in C code and queue up keys in that thread that it can retrieve from java.
Or is there any support in zend that allows me to queue up tasks and a callback that zend can invoke one by one for every task in queue?