Hi all,
I'm trying to use a c library from idris.
This library [1] provides threaded coroutines, useful for non-blocking IO and lightweight signaling, which is very much like the RTS that GHC uses.
As a consequence to this architecture, the library drives the main (epoll based) event loop and expects you to plug your own code into that.
The real (OS level) threads that will actually run the coroutines, will be created by idris' "fork", so they will be fully initialized and from idris' point of view, they will all be running a blocking (ffi) call to the coroutine-scheduler.
To create coroutines (which will get scheduled to any of these threads), you normally (in C) supply a function pointer to the code you want executed.
struct tc_thread *tc_thread_new(void (*func)(void *), void *data, char* name);
I would like to be able to turn an IO () into such a function pointer, but this probably needs some wrapping, as it will be called (inwards) from C.
Is something like this possible? Is it safe?