You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was raised by @gokr. He started writing a brilliant project in Nim but ran into trouble when he needed to use the pharo MQTT library (library link and nim wrapper).
This library exposes an "asynchronous" API which works by using threads in the background. Using this API is necessary to achieve asynchronous operation for Jester.
Side node
As I am writing this, another idea came to me, perhaps @gokr will be willing to try it out:
Use the library's synchronous API in a Nim thread. This will ensure that all threads are handled by nim and thus there should be no trouble.
Indeed, the issues seem to arise when attempting to integrate these "foreign threads" with Nim's handling of threads (per-thread GC). You can see @gokr attempting to get this to work using setupForeignGC.
TL;DR
I have no idea how to wrap libraries that call into Nim code via a call-back from a foreign thread.
We need to figure out the best way to accomplish this and document it.