Fully reworked the event loop public facing API to utilize fibers:
Channels
From:
use parallel\Channel;
use React�ventLoop\Factory;
use ReactParallel�ventLoop�ventLoopBridge;
$loop = Factory::create();
$eventLoopBridge = new EventLoopBridge($loop);
$channel = new Channel(Channel::Infinite);
$eventLoopBridge->observe($channel)->subscribe(function (string $message) {
echo $message, PHP_EOL;
});
$loop->futureTick(function () use ($channel): void {
$channel->send('Hello World!');
$channel->close();
});
$loop->run();
To:
use parallel\Channel;
use React�ventLoop\Loop;
use ReactParallel�ventLoop�ventLoopBridge;
use function React\Async�sync;
use function React\Async�wait;
use function React\Promise\Timer\sleep;
$eventLoopBridge = new EventLoopBridge();
Loop::futureTick(async(static function () use ($eventLoopBridge) {
/** @var Channel<string> */
$channel = new Channel(Channel::Infinite);
Loop::futureTick(async(function () use ($channel): void {
$channel->send('Hello World!');
// Don't close the channel right after writing to it,
// as it will be closed on both ends and the other
// thread won't receive your message
await(sleep(1));
$channel->close();
}));
foreach ($eventLoopBridge->observe($channel) as $message) {
echo $message, PHP_EOL;
}
}));
Futures
From:
use parallel\Channel;
use React�ventLoop\Factory;
use ReactParallel�ventLoop�ventLoopBridge;
use function parallel
un;
$loop = Factory::create();
$eventLoopBridge = new EventLoopBridge($loop);
$future = run(function (): string {
return 'Hello World!';
});
$channel = new Channel(Channel::Infinite);
$eventLoopBridge->await($future)->then(function (string $message) {
echo $message, PHP_EOL;
});
$loop->run();
To:
use React�ventLoop\Loop;
use ReactParallel�ventLoop�ventLoopBridge;
use function parallel
un;
use function React\Async�sync;
$eventLoopBridge = new EventLoopBridge();
Loop::futureTick(async(static function () use ($eventLoopBridge) {
$future = run(function (): string {
return 'Hello World!';
});
echo $eventLoopBridge->await($future), PHP_EOL;
}));
2.0.0
- Total issues resolved: 0
- Total pull requests resolved: 36
- Total contributors: 3
Dependencies 📦,Enhancement ✨
- 63: [2.x] Ensure void return type translates to null thanks to @WyriHaximus
- 59: [2.x] Replace observables with iterables thanks to @WyriHaximus
- 56: [2.x] Bump down to PHP 8.1 thanks to @WyriHaximus
Dependencies 📦,Feature 🏗
- 62: [2.x] Switch to stubs package thanks to @WyriHaximus
- 51: Template types thanks to @WyriHaximus
Dependencies 📦
- 61: Bump composer/composer from 2.4.1 to 2.7.7 thanks to @dependabot[bot]
- 58: Bump guzzlehttp/guzzle from 6.0.0 to 7.9.2 thanks to @dependabot[bot]
- 57: Bump guzzlehttp/guzzle from 6.0.0 to 7.9.1 thanks to @dependabot[bot]
- 55: Bump composer/composer from 2.7.0 to 2.7.7 thanks to @dependabot[bot]
- 53: Bump composer/composer from 2.6.5 to 2.7.0 thanks to @dependabot[bot]
- 52: Add wyrihaximus/react-event-loop-rx-scheduler-hook-up for scheduler hook up thanks to @WyriHaximus
- 49: Update dependency react/promise to v3 thanks to @renovate[bot]
- 48: Update to PHP 8.2+ thanks to @WyriHaximus
- 45: Update dependency reactivex/rxphp to v2.0.11 - autoclosed thanks to @renovate[bot]
- 35: Bump wyrihaximus/async-test-utilities from 3.4.22 to 3.4.24 thanks to @dependabot[bot]
- 33: Bump wyrihaximus/async-test-utilities from 3.4.21 to 3.4.22 thanks to @dependabot[bot]
- 32: Bump wyrihaximus/async-test-utilities from 3.4.20 to 3.4.21 thanks to @dependabot[bot]
- 31: Bump wyrihaximus/async-test-utilities from 3.4.16 to 3.4.20 thanks to @dependabot[bot]
- 28: Bump reactivex/rxphp from 2.0.8 to 2.0.9 thanks to @dependabot[bot]
- 27: Bump wyrihaximus/async-test-utilities from 3.4.13 to 3.4.16 thanks to @dependabot[bot]
- 26: Bump wyrihaximus/async-test-utilities from 3.4.13 to 3.4.15 thanks to @dependabot[bot]
- 25: Bump wyrihaximus/async-test-utilities from 3.4.12 to 3.4.13 thanks to @dependabot[bot]
- 24: Bump wyrihaximus/async-test-utilities from 3.4.11 to 3.4.12 thanks to @dependabot[bot]
- 23: Bump wyrihaximus/async-test-utilities from 3.4.10 to 3.4.11 thanks to @dependabot[bot]
- 22: Bump wyrihaximus/async-test-utilities from 3.4.8 to 3.4.10 thanks to @dependabot[bot]
- 21: Bump wyrihaximus/async-test-utilities from 3.4.7 to 3.4.8 thanks to @dependabot[bot]
- 20: Bump wyrihaximus/async-test-utilities from 3.4.6 to 3.4.7 thanks to @dependabot[bot]
- 19: Bump wyrihaximus/async-test-utilities from 3.4.5 to 3.4.6 thanks to @dependabot[bot]
- 18: Bump wyrihaximus/async-test-utilities from 3.4.4 to 3.4.5 thanks to @dependabot[bot]
- 17: Bump wyrihaximus/async-test-utilities from 3.4.3 to 3.4.4 thanks to @dependabot[bot]
- 16: Bump wyrihaximus/async-test-utilities from 3.4.2 to 3.4.3 thanks to @dependabot[bot]
- 15: Bump wyrihaximus/async-test-utilities from 3.3.3 to 3.4.2 thanks to @dependabot[bot]
- 14: Bump wyrihaximus/async-test-utilities from 3.3.2 to 3.3.3 thanks to @dependabot[bot]
- 13: Bump wyrihaximus/async-test-utilities from 3.3.1 to 3.3.2 thanks to @dependabot[bot]
- 12: Bump wyrihaximus/async-test-utilities from 3.2.0 to 3.3.1 thanks to @dependabot[bot]