m6w6 / atick
Asynchronous resource handling, optionally (ab)using ticks
Installs: 6
Dependents: 0
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
pkg:composer/m6w6/atick
This package is auto-updated.
Last update: 2020-02-10 15:41:40 UTC
README
Asynchronnous resource handling, optionally (ab)using ticks.
Example with ticks:
declare(ticks=1); $conn = new \pq\Connection; $conn->execAsync("SELECT * FROM foo", function ($rs) { var_dump($rs); }); $ticker = new \atick\Ticker; $ticker->register(); $ticker->read($conn->socket, function($fd) use ($conn) { $conn->poll(); if ($conn->busy) { return false; } $conn->getResult(); return true; }); while (count($ticker));
And an example without ticks:
$conn = new \pq\Connection; $conn->execAsync("SELECT * FROM foo", function ($r) { var_dump($r); }); $ticker = new \atick\Ticker; $ticker->read($conn->socket, function($fd) use ($conn) { $conn->poll(); if ($conn->busy) { return false; } $conn->getResult(); return true; }); while($ticker());