I'm writing a C extension, providing an interface between Ruby and an asynchronous I/O library. When running the tests over my code, I frequently get errors including (but not limited to):
[BUG] cross-thread violation in rb_thread_schedule()
Asynchronous IO means my C extension will need to deliver messages to ruby from multiple threads (not the main interpreter thread). How do I avoid these thread-safety violations, in the process?