Skip to content

Commit

Permalink
Merge pull request #32 from Icinga/require-php-event-ext
Browse files Browse the repository at this point in the history
Suggest PHP `ext-ev`
  • Loading branch information
nilmerg authored Mar 7, 2023
2 parents bde2e7d + 9f2e988 commit f85dea3
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 5 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/php.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: phpcs
extensions: ev

- name: Setup dependencies
run: composer require -n --no-progress overtrue/phplint
Expand Down Expand Up @@ -61,6 +62,7 @@ jobs:
with:
php-version: ${{ matrix.php }}
tools: phpunit:${{ env.PHPUNIT_VERSION }}
extensions: ev

- name: Setup dependencies
run: composer install -n --no-progress
Expand Down
3 changes: 3 additions & 0 deletions composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,9 @@
"simshaun/recurr": "^5",
"ipl/stdlib": ">=0.12.0"
},
"suggest": {
"ext-ev": "Improves performance, efficiency and avoids system limitations. Highly recommended! (See https://www.php.net/manual/en/intro.ev.php for details)"
},
"autoload": {
"files": ["src/register_cron_aliases.php"],
"psr-4": {
Expand Down
10 changes: 5 additions & 5 deletions tests/SchedulerTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,14 @@ function (Task $_, array $promises) use (&$canceledPromises): void {
}
);

// Tick callbacks are guaranteed to be executed in the order they are enqueued,
// thus we will not be able to remove the task before it is finished. Therefore,
// we need to use timers with 0 intervals.
Loop::addTimer(0, function () use ($task): void {
// Wait .001ms for the scheduler to run the task at least 2x before removing it und stopping the event loop.
Loop::addTimer(.001, function () use ($task): void {
$this->scheduler->remove($task);

Loop::stop();
});

$this->runAndStopEventLoop();
Loop::run();

// When a task is due before the ongoing promise gets resolved, the scheduler will
// not cancel it. Instead, it will start a new one for the new operations.
Expand Down

0 comments on commit f85dea3

Please sign in to comment.