open-vm-tools 9.2.3
Main Page
Modules
Data Structures
Files
File List
Globals
lib
include
vmware
tools
threadPool.h
Go to the documentation of this file.
1
/*********************************************************
2
* Copyright (C) 2010 VMware, Inc. All rights reserved.
3
*
4
* This program is free software; you can redistribute it and/or modify it
5
* under the terms of the GNU Lesser General Public License as published
6
* by the Free Software Foundation version 2.1 and no later version.
7
*
8
* This program is distributed in the hope that it will be useful, but
9
* WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
10
* or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public
11
* License for more details.
12
*
13
* You should have received a copy of the GNU Lesser General Public License
14
* along with this program; if not, write to the Free Software Foundation, Inc.,
15
* 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
16
*
17
*********************************************************/
18
19
#ifndef _THREADPOOL_H_
20
#define _THREADPOOL_H_
21
48
#include <glib-object.h>
49
#include "
vmware/tools/plugin.h
"
50
51
#define TOOLS_CORE_PROP_TPOOL "tcs_prop_thread_pool"
52
54
typedef
void (*
ToolsCorePoolCb
)(
ToolsAppCtx
*ctx,
55
gpointer data);
56
66
typedef
struct
ToolsCorePool
{
67
guint (*submit)(
ToolsAppCtx
*ctx,
68
ToolsCorePoolCb
cb,
69
gpointer data,
70
GDestroyNotify dtor);
71
void (*cancel)(guint id);
72
gboolean (*start)(
ToolsAppCtx
*ctx,
73
ToolsCorePoolCb
cb,
74
ToolsCorePoolCb
interrupt,
75
gpointer data,
76
GDestroyNotify dtor);
77
}
ToolsCorePool
;
78
79
80
/*
81
*******************************************************************************
82
* ToolsCorePool_GetPool -- */
93
G_INLINE_FUNC
ToolsCorePool
*
94
ToolsCorePool_GetPool
(
ToolsAppCtx
*ctx)
95
{
96
ToolsCorePool
*pool = NULL;
97
g_object_get(ctx->
serviceObj
, TOOLS_CORE_PROP_TPOOL, &pool, NULL);
98
return
pool;
99
}
100
101
102
/*
103
*******************************************************************************
104
* ToolsCorePool_SubmitTask -- */
125
G_INLINE_FUNC guint
126
ToolsCorePool_SubmitTask
(
ToolsAppCtx
*ctx,
127
ToolsCorePoolCb
cb,
128
gpointer data,
129
GDestroyNotify dtor)
130
{
131
ToolsCorePool
*pool =
ToolsCorePool_GetPool
(ctx);
132
if
(pool != NULL) {
133
return
pool->submit(ctx, cb, data, dtor);
134
}
135
return
0;
136
}
137
138
139
/*
140
*******************************************************************************
141
* ToolsCorePool_CancelTask -- */
155
G_INLINE_FUNC
void
156
ToolsCorePool_CancelTask
(
ToolsAppCtx
*ctx,
157
guint taskId)
158
{
159
ToolsCorePool
*pool =
ToolsCorePool_GetPool
(ctx);
160
if
(pool != NULL) {
161
pool->cancel(taskId);
162
}
163
}
164
165
166
/*
167
*******************************************************************************
168
* ToolsCorePool_StartThread -- */
198
G_INLINE_FUNC gboolean
199
ToolsCorePool_StartThread
(
ToolsAppCtx
*ctx,
200
ToolsCorePoolCb
cb,
201
ToolsCorePoolCb
interrupt,
202
gpointer data,
203
GDestroyNotify dtor)
204
{
205
ToolsCorePool
*pool =
ToolsCorePool_GetPool
(ctx);
206
if
(pool != NULL) {
207
return
pool->start(ctx, cb, interrupt, data, dtor);
208
}
209
return
FALSE;
210
}
211
214
#endif
/* _THREADPOOL_H_ */
215
Generated by
1.8.3.1