Interop with Tarantool fibers
Do you have any suggestions on getting cqueues to work seamlessly with Tarantool fibers?
I've interposed step like this, which lets me call :step and :loop within a fiber.
Now I'm trying to get cq.poll() to not cause a "yield across C-call boundary" error when called within a fiber.
I think the issue is that cq.running() doesn't return nil when within a fiber, which make sense. Unfortunately, that behavior makes this line and this line problematic. If those two lines did select(2, cq.running()), it would ensure the current coroutine is a cqueue before doing a native poll.
I may need to handle this by monkey-patching fiber.create, but I'm curious if a simpler solution exists with cqueues. In the end, it may be easiest (but less convenient) to avoid fibers within cqueues at all costs. Thanks!
Another issue: yielding the parent fiber from within a cqueue is nasty business. The cqueue will still think it's running, when in reality its parent fiber is suspended. This makes the return value of core.running incorrect.
At this point, I think forking cqueues to use fibers is the right solution. But I'd like some feedback on this issue first, if possible.
On second thought, I think exposing Tarantool's scheduler so it can be driven with a cqueue could be a viable option. But maybe not, since coroutine.yield is used by cqueues, which Tarantool's scheduler may not like.