• Main Page
  • Modules
  • Data Structures
  • Files
  • File List
  • Globals

lib/include/vmware/tools/threadPool.h

Go to the documentation of this file.
00001 /*********************************************************
00002  * Copyright (C) 2010 VMware, Inc. All rights reserved.
00003  *
00004  * This program is free software; you can redistribute it and/or modify it
00005  * under the terms of the GNU Lesser General Public License as published
00006  * by the Free Software Foundation version 2.1 and no later version.
00007  *
00008  * This program is distributed in the hope that it will be useful, but
00009  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
00010  * or FITNESS FOR A PARTICULAR PURPOSE.  See the Lesser GNU General Public
00011  * License for more details.
00012  *
00013  * You should have received a copy of the GNU Lesser General Public License
00014  * along with this program; if not, write to the Free Software Foundation, Inc.,
00015  * 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA.
00016  *
00017  *********************************************************/
00018 
00019 #ifndef _THREADPOOL_H_
00020 #define _THREADPOOL_H_
00021 
00044 #include <glib-object.h>
00045 #include "vmware/tools/plugin.h"
00046 
00047 #define TOOLS_CORE_PROP_TPOOL "tcs_prop_thread_pool"
00048 
00050 typedef void (*ToolsCorePoolCb)(ToolsAppCtx *ctx,
00051                                 gpointer data);
00052 
00062 typedef struct ToolsCorePool {
00063    guint (*submit)(ToolsAppCtx *ctx,
00064                    ToolsCorePoolCb cb,
00065                    gpointer data,
00066                    GDestroyNotify dtor);
00067    void (*cancel)(guint id);
00068    gboolean (*start)(ToolsAppCtx *ctx,
00069                      ToolsCorePoolCb cb,
00070                      ToolsCorePoolCb interrupt,
00071                      gpointer data,
00072                      GDestroyNotify dtor);
00073 } ToolsCorePool;
00074 
00075 
00076 /*
00077  *******************************************************************************
00078  * ToolsCorePool_GetPool --                                               */ 
00089 G_INLINE_FUNC ToolsCorePool *
00090 ToolsCorePool_GetPool(ToolsAppCtx *ctx)
00091 {
00092    ToolsCorePool *pool = NULL;
00093    g_object_get(ctx->serviceObj, TOOLS_CORE_PROP_TPOOL, &pool, NULL);
00094    return pool;
00095 }
00096 
00097 
00098 /*
00099  *******************************************************************************
00100  * ToolsCorePool_SubmitTask --                                            */ 
00121 G_INLINE_FUNC guint
00122 ToolsCorePool_SubmitTask(ToolsAppCtx *ctx,
00123                          ToolsCorePoolCb cb,
00124                          gpointer data,
00125                          GDestroyNotify dtor)
00126 {
00127    ToolsCorePool *pool = ToolsCorePool_GetPool(ctx);
00128    if (pool != NULL) {
00129       return pool->submit(ctx, cb, data, dtor);
00130    }
00131    return 0;
00132 }
00133 
00134 
00135 /*
00136  *******************************************************************************
00137  * ToolsCorePool_CancelTask --                                            */ 
00151 G_INLINE_FUNC void
00152 ToolsCorePool_CancelTask(ToolsAppCtx *ctx,
00153                          guint taskId)
00154 {
00155    ToolsCorePool *pool = ToolsCorePool_GetPool(ctx);
00156    if (pool != NULL) {
00157       pool->cancel(taskId);
00158    }
00159 }
00160 
00161 
00162 /*
00163  *******************************************************************************
00164  * ToolsCorePool_StartThread --                                           */ 
00194 G_INLINE_FUNC gboolean
00195 ToolsCorePool_StartThread(ToolsAppCtx *ctx,
00196                           ToolsCorePoolCb cb,
00197                           ToolsCorePoolCb interrupt,
00198                           gpointer data,
00199                           GDestroyNotify dtor)
00200 {
00201    ToolsCorePool *pool = ToolsCorePool_GetPool(ctx);
00202    if (pool != NULL) {
00203       return pool->start(ctx, cb, interrupt, data, dtor);
00204    }
00205    return FALSE;
00206 }
00207 
00208 
00209 #endif /* _THREADPOOL_H_ */
00210 

Generated on Mon Feb 21 2011 03:02:40 for open-vm-tools 2011.01.24 by  doxygen 1.7.1