Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[10.x] Adds Countable to the InvokedProcessPool class. #46346

Merged
merged 2 commits into from
Mar 6, 2023
Merged

[10.x] Adds Countable to the InvokedProcessPool class. #46346

merged 2 commits into from
Mar 6, 2023

Conversation

xiCO2k
Copy link
Contributor

@xiCO2k xiCO2k commented Mar 4, 2023

This PR adds a capability to retrieve the total of invokable processes on a pool.

Usage

$pool = Process::pool(function (Pool $pool) {
    $pool->command('sleep 2; echo 1');
    $pool->command('sleep 3; echo 2');
    $pool->command('sleep 1; echo 3');
})->start();

while ($pool->running()->isNotEmpty()) {
    $completed = count($pool) - count($pool->running());
    $this->components->info(sprintf('%d of %d processes completed!', 
        $completed, 
        count($pool)
    ));
}

Cheers.

@xiCO2k xiCO2k changed the title [10.x] Add total method to the InvokedProcessPool. [10.x] Adds total method to the InvokedProcessPool class. Mar 4, 2023
@taylorotwell
Copy link
Member

How about just implementing Countable on the InvokableProcessPool so we can do count($pool)?

@xiCO2k
Copy link
Contributor Author

xiCO2k commented Mar 4, 2023

Even better, will make the change.

@xiCO2k
Copy link
Contributor Author

xiCO2k commented Mar 5, 2023

Done ✅

@xiCO2k xiCO2k changed the title [10.x] Adds total method to the InvokedProcessPool class. [10.x] Adds Countable to the InvokedProcessPool class. Mar 5, 2023
@taylorotwell taylorotwell merged commit ee9487f into laravel:10.x Mar 6, 2023
@taylorotwell
Copy link
Member

Thanks

@xiCO2k xiCO2k deleted the feat/total-processes branch July 21, 2023 00:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants