[libevfibers] interfacing with external resource callbacks

  • From: Phil Carns <carns@xxxxxxxxxxx>
  • To: <libevfibers@xxxxxxxxxxxxx>
  • Date: Thu, 28 May 2015 10:59:23 -0400

Hello,

First of all, many thanks for putting evfibers together- this is a really interesting piece of software. I look forward to trying it out!

What I need to figure out first, though, is how hard it would be to plug in an external resource/library. I see the fbr_eio_custom() function in the existing API, but the library that I have in mind already has its own asynchronous API which itself uses callbacks for completion notification. There is no blocking function for me to execute. As a result, what I really want to do is add my own fbr_foo() function that posts the external operation, and have the callback for that external operation do an ev_async_send() to wake up the event loop in evfibers and continue fiber execution. I'm not sure if I described that properly, but hopefully it makes sense. I'm looking at evfibers as a way to have external library operations *appear* as if they are sequential blocking calls within a fiber.

My question is this: If I want to add my own fbr_foo() function as described above, will I need to actually modify fiber.c to do it? Or does an external user of libevfibers have access to enough internal data structures to be able to interface with the event loop (an inject completion events) from a separate library?

thanks for your time,
-Phil

Other related posts: