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 "common.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 struct bgtask;
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086 typedef bgret_t (*bgstep_cb_t)(struct bgtask *h, gpointer ctx, gint ticks);
00087 typedef void (*bgsig_cb_t)(struct bgtask *h, gpointer ctx, bgsig_t sig);
00088 typedef void (*bgclean_cb_t)(gpointer ctx);
00089 typedef void (*bgdone_cb_t)(struct bgtask *h, gpointer ctx,
00090 bgstatus_t status, gpointer arg);
00091 typedef void (*bgstart_cb_t)(struct bgtask *h, gpointer ctx, gpointer item);
00092 typedef void (*bgend_cb_t)(struct bgtask *h, gpointer ctx, gpointer item);
00093 typedef void (*bgnotify_cb_t)(struct bgtask *h, gboolean on);
00094
00095
00096
00097
00098
00099 void bg_close(void);
00100 void bg_sched_timer(gboolean overloaded);
00101
00102 struct bgtask *bg_task_create(
00103 const gchar *name,
00104 const bgstep_cb_t *steps, gint stepcnt,
00105 gpointer ucontext,
00106 bgclean_cb_t ucontext_free,
00107 bgdone_cb_t done_cb,
00108 gpointer done_arg);
00109
00110 struct bgtask *bg_daemon_create(
00111 const gchar *name,
00112 const bgstep_cb_t *steps, gint stepcnt,
00113 gpointer ucontext,
00114 bgclean_cb_t ucontext_free,
00115 bgstart_cb_t start_cb,
00116 bgend_cb_t end_cb,
00117 bgclean_cb_t item_free,
00118 bgnotify_cb_t notify);
00119
00120 void bg_daemon_enqueue(struct bgtask *h, gpointer item);
00121
00122 void bg_task_cancel(struct bgtask *h);
00123 void bg_task_exit(struct bgtask *h, gint code) G_GNUC_NORETURN;
00124 void bg_task_ticks_used(struct bgtask *h, gint used);
00125 bgsig_cb_t bg_task_signal(struct bgtask *h, bgsig_t sig, bgsig_cb_t handler);
00126
00127 gint bg_task_seqno(const struct bgtask *h);
00128 gpointer bg_task_context(const struct bgtask *h);
00129
00130 #endif
00131
00132