docs
authorMichael Wallner <mike@php.net>
Fri, 8 Mar 2013 11:04:42 +0000 (12:04 +0100)
committerMichael Wallner <mike@php.net>
Fri, 8 Mar 2013 11:04:42 +0000 (12:04 +0100)
README.md [new file with mode: 0644]
lib/atick/Ticker.php

diff --git a/README.md b/README.md
new file mode 100644 (file)
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());
+```
index cdc3364a46891c766a56c0f8f845647e1cc7ab97..1dbf4e8744f1733de2720f91ad55ea7811d49f1b 100644 (file)
@@ -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
         */