Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

bg.h

Go to the documentation of this file.
00001 /*
00002  * $Id: bg.h,v 1.4 2005/06/25 01:37:42 daichik Exp $
00003  *
00004  * Copyright (c) 2002-2003, Raphael Manfredi
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
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  * Signals that a task can receive.
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  * Signatures.
00074  *
00075  * `bgstep_cb_t' is a processing step callback.
00076  * `bgsig_cb_t' is a signal processing handler.
00077  * `bgclean_cb_t' is the context cleanup handler, called upon task destruction.
00078  * `bgdone_cb_t' is the final callback called when task is finished.
00079  * `bgstart_cb_t' is the initial callback when daemon starts working.
00080  * `bgend_cb_t' is the final callback when daemon ends working.
00081  * `bgnotify_cb_t' is the start/stop callback when daemon starts/stops working.
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  * Public interface.
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  /* _bg_h_ */
00129 
00130 /* vi: set ts=4 sw=4 cindent: */

Generated on Sun Feb 12 10:49:55 2006 for Gtk-Gnutella by doxygen 1.3.6