4
* Copyright 2008 PCMan <pcman.tw@gmail.com>
6
* This program is free software; you can redistribute it and/or modify
7
* it under the terms of the GNU General Public License as published by
8
* the Free Software Foundation; either version 2 of the License, or
9
* (at your option) any later version.
11
* This program is distributed in the hope that it will be useful,
12
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14
* GNU General Public License for more details.
16
* You should have received a copy of the GNU General Public License
17
* along with this program; if not, write to the Free Software
18
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
23
#ifndef __VFS_ASYNC_TASK_H__
24
#define __VFS_ASYNC_TASK_H__
27
#include <glib-object.h>
31
#define VFS_ASYNC_TASK_TYPE (vfs_async_task_get_type())
32
#define VFS_ASYNC_TASK(obj) (G_TYPE_CHECK_INSTANCE_CAST((obj),\
33
VFS_ASYNC_TASK_TYPE, VFSAsyncTask))
34
#define VFS_ASYNC_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_CAST((klass),\
35
VFS_ASYNC_TASK_TYPE, VFSAsyncTaskClass))
36
#define VFS_IS_ASYNC_TASK(obj) (G_TYPE_CHECK_INSTANCE_TYPE((obj),\
38
#define VFS_IS_ASYNC_TASK_CLASS(klass) (G_TYPE_CHECK_CLASS_TYPE((klass),\
41
typedef struct _VFSAsyncTask VFSAsyncTask;
42
typedef struct _VFSAsyncTaskClass VFSAsyncTaskClass;
44
typedef gpointer (*VFSAsyncFunc)( VFSAsyncTask*, gpointer );
58
gboolean cancelled : 1;
59
gboolean finished : 1;
62
struct _VFSAsyncTaskClass
64
GObjectClass parent_class;
65
void (*finish)( VFSAsyncTask* task, gboolean is_cancelled );
68
GType vfs_async_task_get_type (void);
69
VFSAsyncTask* vfs_async_task_new ( VFSAsyncFunc task_func, gpointer user_data );
71
gpointer vfs_async_task_get_data( VFSAsyncTask* task );
72
void vfs_async_task_set_data( VFSAsyncTask* task, gpointer user_data );
73
gpointer vfs_async_task_get_return_value( VFSAsyncTask* task );
75
/* Execute the async task */
76
void vfs_async_task_execute( VFSAsyncTask* task );
78
gboolean vfs_async_task_is_finished( VFSAsyncTask* task );
79
gboolean vfs_async_task_is_cancelled( VFSAsyncTask* task );
82
* Cancel the async task running in another thread.
83
* NOTE: Only can be called from main thread.
85
void vfs_async_task_cancel( VFSAsyncTask* task );
87
void vfs_async_task_lock( VFSAsyncTask* task );
88
void vfs_async_task_unlock( VFSAsyncTask* task );
92
#endif /* __VFS_ASYNC_TASK_H__ */