Closed sacOO7 closed 2 weeks ago
If it uses fibers internally, why isn't is build on top of ampPhp and reactPhp instead
Hi, No simple answers to your questions but I'll give it a try.
This library uses a custom coroutine setup, similar to Fibers but limited/optimized for actually use. I have considered switching to Fibers but as the functional benefit is pretty low it's not a priority at this point.
The listener callbacks are invoked after a message have been read from stream, so they're not blocking as such - unless you add blocking code in them.
I'm not familiar with mentioned libraries, but maybe someone else can make a comparison.
Thanks for the answer ! Btw, I was interested in your custom coroutine setup : > Can you point me to the code ?
The run loop is in the start()
method of Server and Client respectively.
The "queue" is populated by waitRead()
that in turn uses stream_select()
. This way the entire instance share a single wait state, connections will never block each other.
So it's not a generalized coroutine setup (although there is a onTick(...)
listener that allows adding custom code).
Is code written inside >onText blocking or nonblocking? Does this library make use of php fibres to achieve concurrency ? How is this library different from https://github.com/amphp/websocket-client and https://github.com/ratchetphp/Pawl