11 $loop->nextTick(
function() use (&$check) {
19 $this->assertEquals(1, $check);
27 $loop->setTimeout(
function() use (&$check) {
35 $this->assertEquals(1, $check);
43 $loop->setTimeout(
function() use (&$check) {
48 $loop->setTimeout(
function() use (&$check) {
53 $loop->setTimeout(
function() use (&$check) {
61 $this->assertEquals([
'b',
'a',
'c'], $check);
70 $intervalId = $loop->setInterval(
function() use (&$check, &$intervalId, $loop) {
74 $loop->clearInterval($intervalId);
80 $this->assertEquals(6, $check);
88 $loop->addWriteStream(
$h,
function() use (
$h, $loop) {
90 fwrite(
$h,
'hello world');
91 $loop->removeWriteStream(
$h);
96 $this->assertEquals(
'hello world', stream_get_contents(
$h));
102 $h =
fopen(
'php://temp',
'r+');
103 fwrite(
$h,
'hello world');
110 $loop->addReadStream(
$h,
function() use (
$h, $loop, &
$result) {
113 $loop->removeReadStream(
$h);
117 $this->assertEquals(
'hello world',
$result);
125 $loop->setTimeout(
function() use (&$check) {
129 $loop->nextTick(
function() use ($loop) {
134 $this->assertEquals(0, $check);
142 $loop->setTimeout(
function() use (&$check) {
146 $loop->nextTick(
function() use ($loop, &$check) {
151 $this->assertEquals(1, $check);
163 $loop->nextTick(
function() use (&$check, $loop) {
165 $loop->nextTick(
function() use (&$check) {
176 $this->assertEquals(2, $check);
testNextTickStacking()
Here we add a new nextTick function as we're in the middle of a current nextTick. ...
A simple eventloop implementation.