Hello,

I am looking for advise on how to accomplish something using boost thread algorithms.

Scenario: We have created an Firefox extension that must run on windows and eventually the Mac. We have created a C++ library (DLL for windows soon to be a library on the Mac) that implements a lengthy procedure that must call back to a JavaScript function in the extension codebase. We have tested the callback and it can be called in the main thread of the DLL. However calling the function from a worker thread will result in an unhandled exception being thrown. The exception is thrown because the function in not called in the same thread context as the library main thread. For all practical purposes the JavaScript callback does not support a multithreaded environment.

We have tried many different things (binding) to try to get the callback to be called from the main thread…but all attempts fail. I have thought about solutions for windows that may work by utilizing PostThreadMessage, but we really want a solution that will work on all operating systems.

I have seen a lot about boost::asio, but I cannot figure out how to implement this in a DLL in an asynchronous manner.

Does anybody have any suggestions?

Thanks,
Tom