Created
August 25, 2014 20:47
-
-
Save steverhoades/c7d2528491418bd06bd5 to your computer and use it in GitHub Desktop.
Blocking test with Event extension
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
require __DIR__ . '/../vendor/autoload.php'; | |
/** @var $loop \React\EventLoop\ExtEventLoop */ | |
$cfg = new \EventConfig(); | |
$cfg->requireFeatures(\EventConfig::FEATURE_FDS); | |
$loop = new \React\EventLoop\ExtEventLoop($cfg); | |
$dir = getcwd(); | |
$fd = fopen($dir . DIRECTORY_SEPARATOR . 'largefile', "r"); | |
stream_set_blocking($fd, 0); | |
$stream = new \React\Stream\Stream($fd, $loop); | |
$stream->on('data', function() { echo 'large file read'. PHP_EOL; }); | |
$loop->addPeriodicTimer(0.01, function() { echo "Timer". PHP_EOL; }); | |
$loop->run(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment