X-Git-Url: http://mj.ucw.cz/gitweb/?a=blobdiff_plain;f=lib%2Fmainloop.h;h=f321c2b5fc85e57402d1a4c2741b1deea26f2bcd;hb=6a26177ec0df11f55bff590d63ea02e7c9884993;hp=434f639b4add70fa4a99732f98a4b279849727ec;hpb=bcc5c58a105eb298a71eb751d0ae450a9c50c005;p=libucw.git diff --git a/lib/mainloop.h b/lib/mainloop.h index 434f639b..f321c2b5 100644 --- a/lib/mainloop.h +++ b/lib/mainloop.h @@ -7,6 +7,9 @@ * of the GNU Lesser General Public License. */ +#ifndef _UCW_MAINLOOP_H +#define _UCW_MAINLOOP_H + #include "lib/clists.h" typedef s64 timestamp_t; /* We measure time in milliseconds */ @@ -29,6 +32,8 @@ struct main_timer { void timer_add(struct main_timer *tm, timestamp_t expires); /* Can modify a running timer, too */ void timer_del(struct main_timer *tm); +void main_get_time(void); /* Refresh main_now */ + /* Files to poll */ struct main_file { @@ -66,10 +71,17 @@ void file_close_all(void); /* Close all known main_file's; frequently used bef struct main_hook { cnode n; - int (*handler)(struct main_hook *ho); /* [*] Hook function; returns 1 if should be called again */ + int (*handler)(struct main_hook *ho); /* [*] Hook function; returns HOOK_xxx */ void *data; /* [*] For use by the handler */ }; +enum main_hook_return { + HOOK_IDLE, /* Call again when the main loop becomes idle again */ + HOOK_RETRY, /* Call again as soon as possible */ + HOOK_DONE = -1, /* Shut down the main loop if all hooks return this value */ + HOOK_SHUTDOWN = -2 /* Shut down the main loop immediately */ +}; + void hook_add(struct main_hook *ho); void hook_del(struct main_hook *ho); @@ -93,3 +105,5 @@ int process_fork(struct main_process *mp); void main_init(void); void main_loop(void); void main_debug(void); + +#endif