]> mj.ucw.cz Git - libucw.git/blobdiff - lib/mainloop.h
documented fbpool briefly
[libucw.git] / lib / mainloop.h
index a8626f0345c2672ef20883cb2edd2e2b6b05d83b..136d90e04858c1c3b4112c41d8c21dd9c53475d4 100644 (file)
@@ -12,7 +12,6 @@
 
 #include "lib/clists.h"
 
 
 #include "lib/clists.h"
 
-typedef s64 timestamp_t;                       /* We measure time in milliseconds */
 extern timestamp_t main_now;                   /* Current time in milliseconds since UNIX epoch */
 extern sh_time_t main_now_seconds;             /* Current time in seconds since the epoch */
 extern uns main_shutdown;
 extern timestamp_t main_now;                   /* Current time in milliseconds since UNIX epoch */
 extern sh_time_t main_now_seconds;             /* Current time in seconds since the epoch */
 extern uns main_shutdown;
@@ -71,10 +70,17 @@ void file_close_all(void);                  /* Close all known main_file's; frequently used bef
 
 struct main_hook {
   cnode n;
 
 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 */
 };
 
   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);
 
 void hook_add(struct main_hook *ho);
 void hook_del(struct main_hook *ho);
 
@@ -96,7 +102,7 @@ int process_fork(struct main_process *mp);
 /* The main loop */
 
 void main_init(void);
 /* The main loop */
 
 void main_init(void);
-int main_loop(void);
+void main_loop(void);
 void main_debug(void);
 
 #endif
 void main_debug(void);
 
 #endif