00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 
00023 
00024 
00025 
00036 #ifndef _bg_h_
00037 #define _bg_h_
00038 
00039 #include <glib.h>
00040 
00044 typedef enum {
00045     BGR_NEXT = 0,                   
00046     BGR_MORE,                       
00047     BGR_DONE,                       
00048     BGR_ERROR                       
00049 } bgret_t;
00050 
00054 typedef enum {
00055     BGS_OK = 0,                     
00056     BGS_ERROR,                      
00057     BGS_KILLED                      
00058 } bgstatus_t;
00059 
00060 
00061 
00062 
00063 
00064 typedef enum {
00065     BG_SIG_ZERO = 0,                
00066     BG_SIG_KILL,                    
00067     BG_SIG_TERM,                    
00068     BG_SIG_USR,                     
00069     BG_SIG_COUNT
00070 } bgsig_t;
00071 
00072 
00073 
00074 
00075 
00076 
00077 
00078 
00079 
00080 
00081 
00082 
00083 
00084 typedef bgret_t (*bgstep_cb_t)(gpointer h, gpointer ctx, gint ticks);
00085 typedef void (*bgsig_cb_t)(gpointer h, gpointer ctx, bgsig_t sig);
00086 typedef void (*bgclean_cb_t)(gpointer ctx);
00087 typedef void (*bgdone_cb_t)(gpointer h, gpointer ctx,
00088     bgstatus_t status, gpointer arg);
00089 typedef void (*bgstart_cb_t)(gpointer h, gpointer ctx, gpointer item);
00090 typedef void (*bgend_cb_t)(gpointer h, gpointer ctx, gpointer item);
00091 typedef void (*bgnotify_cb_t)(gpointer h, gboolean on);
00092 
00093 
00094 
00095 
00096 
00097 void bg_close(void);
00098 void bg_sched_timer(void);
00099 
00100 gpointer bg_task_create(
00101     gchar *name,                        
00102     bgstep_cb_t *steps, gint stepcnt,   
00103     gpointer ucontext,                  
00104     bgclean_cb_t ucontext_free,         
00105     bgdone_cb_t done_cb,                
00106     gpointer done_arg);                 
00108 gpointer bg_daemon_create(
00109     gchar *name,                        
00110     bgstep_cb_t *steps, gint stepcnt,   
00111     gpointer ucontext,                  
00112     bgclean_cb_t ucontext_free,         
00113     bgstart_cb_t start_cb,              
00114     bgend_cb_t end_cb,                  
00115     bgclean_cb_t item_free,             
00116     bgnotify_cb_t notify);              
00118 void bg_daemon_enqueue(gpointer h, gpointer item);
00119 
00120 void bg_task_cancel(gpointer h);
00121 void bg_task_exit(gpointer h, gint code) G_GNUC_NORETURN;
00122 void bg_task_ticks_used(gpointer h, gint used);
00123 bgsig_cb_t bg_task_signal(gpointer h, bgsig_t sig, bgsig_cb_t handler);
00124 
00125 gint bg_task_seqno(gpointer h);
00126 gpointer bg_task_context(gpointer h);
00127 
00128 #endif  
00129 
00130