~ubuntu-branches/ubuntu/trusty/pcmanfm/trusty-proposed

« back to all changes in this revision

Viewing changes to src/vfs/vfs-async-task.h

  • Committer: Bazaar Package Importer
  • Author(s): Andrew Lee
  • Date: 2008-09-26 10:19:20 UTC
  • mfrom: (4.1.5 intrepid)
  • Revision ID: james.westby@ubuntu.com-20080926101920-cfldybkmwgwrtv9u
Tags: 0.5-3
* Correct spellings,  03_correct_spelling.dpatch (Closes:498794) 
* Code in some files are taken from other projects, added these
  informations into copyright file. (Closes:499678)
* Applied 04_defaut_terminal.dpatch to support x-terminal-emulator
  alternative. (Closes:497494) 

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *      vfs-async-task.h
 
3
 *
 
4
 *      Copyright 2008 PCMan <pcman.tw@gmail.com>
 
5
 *
 
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.
 
10
 *
 
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.
 
15
 *
 
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,
 
19
 *      MA 02110-1301, USA.
 
20
 */
 
21
 
 
22
 
 
23
#ifndef __VFS_ASYNC_TASK_H__
 
24
#define __VFS_ASYNC_TASK_H__
 
25
 
 
26
#include <glib.h>
 
27
#include <glib-object.h>
 
28
 
 
29
G_BEGIN_DECLS
 
30
 
 
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),\
 
37
        VFS_ASYNC_TASK_TYPE))
 
38
#define VFS_IS_ASYNC_TASK_CLASS(klass)      (G_TYPE_CHECK_CLASS_TYPE((klass),\
 
39
        VFS_ASYNC_TASK_TYPE))
 
40
 
 
41
typedef struct _VFSAsyncTask                VFSAsyncTask;
 
42
typedef struct _VFSAsyncTaskClass           VFSAsyncTaskClass;
 
43
 
 
44
typedef gpointer (*VFSAsyncFunc)( VFSAsyncTask*, gpointer );
 
45
 
 
46
struct _VFSAsyncTask
 
47
{
 
48
    GObject parent;
 
49
    VFSAsyncFunc func;
 
50
    gpointer user_data;
 
51
    gpointer ret_val;
 
52
 
 
53
    GThread* thread;
 
54
    GMutex* lock;
 
55
 
 
56
    guint idle_id;
 
57
    gboolean cancel : 1;
 
58
    gboolean cancelled : 1;
 
59
    gboolean finished : 1;
 
60
};
 
61
 
 
62
struct _VFSAsyncTaskClass
 
63
{
 
64
    GObjectClass parent_class;
 
65
    void (*finish)( VFSAsyncTask* task, gboolean is_cancelled );
 
66
};
 
67
 
 
68
GType       vfs_async_task_get_type (void);
 
69
VFSAsyncTask*    vfs_async_task_new          ( VFSAsyncFunc task_func, gpointer user_data );
 
70
 
 
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 );
 
74
 
 
75
/* Execute the async task */
 
76
void vfs_async_task_execute( VFSAsyncTask* task );
 
77
 
 
78
gboolean vfs_async_task_is_finished( VFSAsyncTask* task );
 
79
gboolean vfs_async_task_is_cancelled( VFSAsyncTask* task );
 
80
 
 
81
/*
 
82
 * Cancel the async task running in another thread.
 
83
 * NOTE: Only can be called from main thread.
 
84
 */
 
85
void vfs_async_task_cancel( VFSAsyncTask* task );
 
86
 
 
87
void vfs_async_task_lock( VFSAsyncTask* task );
 
88
void vfs_async_task_unlock( VFSAsyncTask* task );
 
89
 
 
90
G_END_DECLS
 
91
 
 
92
#endif /* __VFS_ASYNC_TASK_H__ */