1 /* 2 * Copyright (C) 2005 - 2007 Murray Cumming <murrayc@murrayc.com> 3 * Copyright (C) 2005 - 2011 Vivien Malerba <malerba@gnome-db.org> 4 * 5 * This program is free software; you can redistribute it and/or 6 * modify it under the terms of the GNU General Public License 7 * as published by the Free Software Foundation; either version 2 8 * of the License, or (at your option) any later version. 9 * 10 * This program is distributed in the hope that it will be useful, 11 * but WITHOUT ANY WARRANTY; without even the implied warranty of 12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 13 * GNU General Public License for more details. 14 * 15 * You should have received a copy of the GNU General Public License 16 * along with this program; if not, write to the Free Software 17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 18 */ 19 20 #ifndef __GDA_THREADER_H_ 21 #define __GDA_THREADER_H_ 22 23 #include <glib-object.h> 24 25 G_BEGIN_DECLS 26 27 #define GDA_TYPE_THREADER (gda_threader_get_type()) 28 #define GDA_THREADER(obj) G_TYPE_CHECK_INSTANCE_CAST (obj, gda_threader_get_type(), GdaThreader) 29 #define GDA_THREADER_CLASS(klass) G_TYPE_CHECK_CLASS_CAST (klass, gda_threader_get_type (), GdaThreaderClass) 30 #define GDA_IS_THREADER(obj) G_TYPE_CHECK_INSTANCE_TYPE (obj, gda_threader_get_type ()) 31 32 33 typedef struct _GdaThreader GdaThreader; 34 typedef struct _GdaThreaderClass GdaThreaderClass; 35 typedef struct _GdaThreaderPrivate GdaThreaderPrivate; 36 typedef void (*GdaThreaderFunc) (GdaThreader *, guint, gpointer); 37 38 /* struct for the object's data */ 39 struct _GdaThreader 40 { 41 GObject object; 42 GdaThreaderPrivate *priv; 43 }; 44 45 /* struct for the object's class */ 46 struct _GdaThreaderClass 47 { 48 GObjectClass parent_class; 49 50 /* signals */ 51 void (*finished) (GdaThreader *thread, guint job_id, gpointer arg_data); 52 void (*cancelled) (GdaThreader *thread, guint job_id, gpointer arg_data); 53 }; 54 55 GType gda_threader_get_type (void) G_GNUC_CONST; 56 GObject *gda_threader_new (void); 57 58 guint gda_threader_start_thread (GdaThreader *thread, GThreadFunc func, gpointer func_arg, 59 GdaThreaderFunc ok_callback, GdaThreaderFunc cancel_callback, 60 GError **error); 61 void gda_threader_cancel (GdaThreader *thread, guint job_id); 62 G_END_DECLS 63 64 #endif 65