application-driven events in libevent

703 Views Asked by At

I'd like to use libevent to prototype an event-driven application. Specifically, I want to use the PHP libevent extension.

What I'm wondering is the following. libevent seems to revolve around open file handler/socket/streams events. I'd like to be able to throw my own application-driven events for communication.

So, how would one use a file handle to pass around custom events? Is this really the way to go?

1

There are 1 best solutions below

0
On BEST ANSWER

The solution for this is as follows..

There's no need to deal with non io-based events in this manner, as they will never have to end up in the event loop.

The rule is pretty much, "all io-based events are added to the loop, all other events are executed immediately".

This does leave me with the issue of having to 'fake' events, or simply have slightly deferred execution. libevent does provide timed events, and there is a PHP api for this but it's undocumented and I couldn't get it to work.