From 36599097d59b4a0d61151762394a3f13ec78bcd6 Mon Sep 17 00:00:00 2001 From: Joachim Nilsson Date: Tue, 19 Sep 2017 09:05:08 +0200 Subject: [PATCH] README: Add a simple example Signed-off-by: Joachim Nilsson --- README.md | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index f8e2272..a25251a 100644 --- a/README.md +++ b/README.md @@ -32,7 +32,30 @@ For details, see [this article][4] at [lwn.net](http://lwn.net). 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 +#include + +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