From: Michael Wallner Date: Fri, 8 Mar 2013 11:04:42 +0000 (+0100) Subject: docs X-Git-Url: https://git.m6w6.name/?p=m6w6%2Fatick;a=commitdiff_plain;h=e67f84aed03307cfb4c1b6584dfc56de6be1be92 docs --- diff --git a/README.md b/README.md new file mode 100644 index 0000000..56d7ef4 --- /dev/null +++ b/README.md @@ -0,0 +1,49 @@ +atick\Ticker +============ + +Asynchronnous resource handling, optionally (ab)using ticks + +**Example with ticks:** + +```PHP +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:** + +```php +$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()); +``` diff --git a/lib/atick/Ticker.php b/lib/atick/Ticker.php index cdc3364..1dbf4e8 100644 --- a/lib/atick/Ticker.php +++ b/lib/atick/Ticker.php @@ -121,6 +121,7 @@ class Ticker implements \Countable } /** + * Returns the count of watched fds * @implements \Countable * @return int */ @@ -141,7 +142,7 @@ class Ticker implements \Countable /** * Attach a write handler; let the callback return true, to stop watching the fd. - * @param int $fd + * @param resource $fd * @param callable $cb * @return \atick\Ticker */