About the project: https://github.com/danielecr/CurlParallel
Selfing on the net this morning I discovered at least another interesting implementation of parallel fetch of network resource via PHP curl, that is https://github.com/dulao5/parallel-curl of https://github.com/dulao5, and is older than the one I take as starting point.
Also that solution put focus on tasks to be managed not in curl by itself, thus giving more weight to the use of network resource, and less on the implementation specific part. He also does a good and extended use of Standard PHP Library (SPL). Definitely areas on which my implementation have to pay attention.
Seeing from different point of views (and implementation) make clear that it does not parallelize execution, but parallelize waiting of I/O, the client classes are not executed in parallel, but executeted with an undefined order, say you know that the whole block of code is executed from start to the end without interleaving other client’s instruction.
This can cause some problem in term of memory required, and balancing how much elaboration has to be done during consume phase: it should be done at least all elaboration that warrant to throw out unuseful data that occupy not needed memory, but it might be needed to defer some operation on following code, say, instead of write report, there is a collector class that can destroy some instances and require more processing for some else. The need to do this operation could arose from the presence or absense of a specific resource, part of the requested pool. Obviously act early is better e things become complex when the same consumer asks if it is the case to throw out the received buffer because the “main” resource “has said no”.
(specials thanks to dia developer https://live.gnome.org/Dia)