You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Oct 14, 2022. It is now read-only.
It's currently impossible to run multiple Node instructions in parallel. Adding this feature would be great for some Rialto implementations, like PuPHPeteer, where making multiple page navigations in parallel would save time.
Proposed API
Due to the synchrone nature of PHP, it's impossible to run and wait for multiple instructions at the same time. However, it is possible to store the instructions and send them all at once to Node, which will answer only once all the instructions are done.
Here's what the API could look like (using PuPHPeteer as the implementation):
The user starts parallelization (Rialto switches ON a flag available to all resources).
All the instructions made by the user are stored in a buffer instead of being immediately sent to the Node process.
The user stops parallelization (Rialto switches OFF the flag).
The process supervisor sends all the previously stored instructions at once to the Node process (in a special parallelization data container).
The Node process executes all the instructions and returns all of their values at once.
The user can now read the values returned by all the instructions, in the order they have been executed.
The API can be confusing
Since instructions aren't executed immediately, it is not possible to chain them while in parallelization, this will not work:
Puppeteer::parallelize(function () use ($page1) {
echo$page1->goto('https://github.com/nesk/')->status();
});
This is not a solvable issue, however we must properly warn the user. To address this, we could make the parallelized instructions return a PendingParallelResource which throws an exception when trying to make any call/get/set on it.
The problem
It's currently impossible to run multiple Node instructions in parallel. Adding this feature would be great for some Rialto implementations, like PuPHPeteer, where making multiple page navigations in parallel would save time.
Proposed API
Due to the synchrone nature of PHP, it's impossible to run and wait for multiple instructions at the same time. However, it is possible to store the instructions and send them all at once to Node, which will answer only once all the instructions are done.
Here's what the API could look like (using PuPHPeteer as the implementation):
How it works
The workflow is the following:
The API can be confusing
Since instructions aren't executed immediately, it is not possible to chain them while in parallelization, this will not work:
This is not a solvable issue, however we must properly warn the user. To address this, we could make the parallelized instructions return a
PendingParallelResource
which throws an exception when trying to make any call/get/set on it.Original idea from #2 by @mdeora
The text was updated successfully, but these errors were encountered: