mirror of
https://github.com/troglobit/libuev.git
synced 2026-11-30 21:28:39 +00:00
README: Add a simple example
Signed-off-by: Joachim Nilsson <troglobit@gmail.com>
This commit is contained in:
1 parent
ca7a99aba3
commit
36599097d5
1 file changed
+24
-1
@@ -32,7 +32,30 @@ For details, see [this article][4] at [lwn.net](http://lwn.net).
|
|||||||
Documentation
|
Documentation
|
||||||
-------------
|
-------------
|
||||||
|
|
||||||
The API documentation is available as a [separate document](API.md).
|
The library documentation is available as a [separate document](API.md).
|
||||||
|
|
||||||
|
**Example:**
|
||||||
|
|
||||||
|
```C
|
||||||
|
#include <stdio.h>
|
||||||
|
#include <uev/uev.h>
|
||||||
|
|
||||||
|
static void cb(uev_t *w, void *arg, int events)
|
||||||
|
{
|
||||||
|
printf("Callback runs every other second.\n");
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
uev_t timer;
|
||||||
|
uev_ctx_t *ctx;
|
||||||
|
|
||||||
|
uev_init(&ctx);
|
||||||
|
uev_timer_init(&ctx, &timer, cb, NULL, 2 * 1000, 0);
|
||||||
|
|
||||||
|
return uev_run(&ctx, 0);
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
|
||||||
Build & Install
|
Build & Install
|
||||||
|
|||||||
Reference in new issue
Block a user