1 #include <stdio.h> 2 3 #include <uv.h> 4 5 uv_loop_t *loop; 6 uv_timer_t gc_req; 7 uv_timer_t fake_job_req; 8 9 void gc(uv_timer_t *handle) { 10 fprintf(stderr, "Freeing unused objects\n"); 11 } 12 13 void fake_job(uv_timer_t *handle) { 14 fprintf(stdout, "Fake job done\n"); 15 } 16 17 int main() { 18 loop = uv_default_loop(); 19 20 uv_timer_init(loop, &gc_req); 21 uv_unref((uv_handle_t*) &gc_req); 22 23 uv_timer_start(&gc_req, gc, 0, 2000); 24 25 // could actually be a TCP download or something 26 uv_timer_init(loop, &fake_job_req); 27 uv_timer_start(&fake_job_req, fake_job, 9000, 0); 28 return uv_run(loop, UV_RUN_DEFAULT); 29 } 30