-
-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Automatically run Loop at end of program (autorun)
- Loading branch information
Showing
19 changed files
with
133 additions
and
40 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,3 @@ | |
Loop::addTimer(0.3, function () { | ||
echo 'hello '; | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,5 +12,3 @@ | |
Loop::cancelTimer($timer); | ||
echo 'Done' . PHP_EOL; | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,5 +11,3 @@ | |
echo 'c'; | ||
}); | ||
echo 'a'; | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,5 +15,3 @@ | |
}); | ||
|
||
echo 'Listening for SIGINT. Use "kill -SIGINT ' . getmypid() . '" or CTRL+C' . PHP_EOL; | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -24,5 +24,3 @@ | |
|
||
echo strlen($chunk) . ' bytes' . PHP_EOL; | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -37,5 +37,3 @@ | |
$data = substr($data, $r) . substr($data, 0, $r); | ||
} | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -29,5 +29,3 @@ | |
|
||
echo $chunk; | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -58,5 +58,3 @@ | |
echo $chunk; | ||
}); | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -32,5 +32,3 @@ | |
$formatted = number_format($memory, 3).'K'; | ||
echo "Current memory usage: {$formatted}\n"; | ||
}); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,3 @@ | |
for ($i = 0; $i < $n; ++$i) { | ||
Loop::futureTick(function () { }); | ||
} | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -9,5 +9,3 @@ | |
for ($i = 0; $i < $n; ++$i) { | ||
Loop::addTimer(0, function () { }); | ||
} | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,3 @@ | |
}; | ||
|
||
$tick(); | ||
|
||
Loop::run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -16,5 +16,3 @@ | |
}; | ||
|
||
$tick(); | ||
|
||
Loop::run(); |
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<?php | ||
|
||
namespace React\Tests\EventLoop; | ||
|
||
class BinTest extends TestCase | ||
{ | ||
/** | ||
* @before | ||
*/ | ||
public function setUpBin() | ||
{ | ||
if (!defined('PHP_BINARY') || defined('HHVM_VERSION')) { | ||
$this->markTestSkipped('Tests not supported on legacy PHP 5.3 or HHVM'); | ||
} | ||
|
||
chdir(__DIR__ . '/bin/'); | ||
} | ||
|
||
public function testExecuteExampleWithoutLoopRunRunsLoopAndExecutesTicks() | ||
{ | ||
$output = exec(escapeshellarg(PHP_BINARY) . ' 01-ticks-loop-class.php'); | ||
|
||
$this->assertEquals('abc', $output); | ||
} | ||
|
||
public function testExecuteExampleWithExplicitLoopRunRunsLoopAndExecutesTicks() | ||
{ | ||
$output = exec(escapeshellarg(PHP_BINARY) . ' 02-ticks-loop-instance.php'); | ||
|
||
$this->assertEquals('abc', $output); | ||
} | ||
|
||
public function testExecuteExampleWithExplicitLoopRunAndStopRunsLoopAndExecutesTicksUntilStopped() | ||
{ | ||
$output = exec(escapeshellarg(PHP_BINARY) . ' 03-ticks-loop-stop.php'); | ||
|
||
$this->assertEquals('abc', $output); | ||
} | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
<?php | ||
|
||
use React\EventLoop\Loop; | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
Loop::futureTick(function () { | ||
echo 'b'; | ||
}); | ||
Loop::futureTick(function () { | ||
echo 'c'; | ||
}); | ||
echo 'a'; |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
<?php | ||
|
||
use React\EventLoop\Loop; | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$loop = Loop::get(); | ||
|
||
$loop->futureTick(function () { | ||
echo 'b'; | ||
}); | ||
|
||
$loop->futureTick(function () { | ||
echo 'c'; | ||
}); | ||
|
||
echo 'a'; | ||
|
||
$loop->run(); |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
<?php | ||
|
||
use React\EventLoop\Loop; | ||
|
||
require __DIR__ . '/../../vendor/autoload.php'; | ||
|
||
$loop = Loop::get(); | ||
|
||
$loop->futureTick(function () use ($loop) { | ||
echo 'b'; | ||
|
||
$loop->stop(); | ||
|
||
$loop->futureTick(function () { | ||
echo 'never'; | ||
}); | ||
}); | ||
|
||
echo 'a'; | ||
|
||
$loop->run(); | ||
|
||
echo 'c'; |