epoc32/include/stdapis/glib-2.0/glib/gthreadpool.h
author William Roberts <williamr@symbian.org>
Wed, 31 Mar 2010 12:33:34 +0100
branchSymbian3
changeset 4 837f303aceeb
parent 0 061f57f2323e
permissions -rw-r--r--
Current Symbian^3 public API header files (from PDK 3.0.h)
This is the epoc32/include tree with the "platform" subtrees removed, and
all but a selected few mbg and rsg files removed.
     1 /* GLIB - Library of useful routines for C programming
     2  * Copyright (C) 1995-1997  Peter Mattis, Spencer Kimball and Josh MacDonald
     3  * Portions copyright (c) 2006 Nokia Corporation.  All rights reserved.
     4  *
     5  * This library is free software; you can redistribute it and/or
     6  * modify it under the terms of the GNU Lesser General Public
     7  * License as published by the Free Software Foundation; either
     8  * version 2 of the License, or (at your option) any later version.
     9  *
    10  * This library 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 GNU
    13  * Lesser General Public License for more details.
    14  *
    15  * You should have received a copy of the GNU Lesser General Public
    16  * License along with this library; if not, write to the
    17  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
    18  * Boston, MA 02111-1307, USA.
    19  */
    20 
    21 /*
    22  * Modified by the GLib Team and others 1997-2000.  See the AUTHORS
    23  * file for a list of people on the GLib Team.  See the ChangeLog
    24  * files for a list of changes.  These files are distributed with
    25  * GLib at ftp://ftp.gtk.org/pub/gtk/. 
    26  */
    27 
    28 #ifndef __G_THREADPOOL_H__
    29 #define __G_THREADPOOL_H__
    30 
    31 #include <_ansi.h>
    32 #include <glib/gthread.h>
    33 
    34 G_BEGIN_DECLS
    35 
    36 typedef struct _GThreadPool     GThreadPool;
    37 
    38 /* Thread Pools
    39  */
    40 
    41 /* The real GThreadPool is bigger, so you may only create a thread
    42  * pool with the constructor function */
    43 struct _GThreadPool
    44 {
    45   GFunc func;
    46   gpointer user_data;
    47   gboolean exclusive;
    48 };
    49 
    50 /* Get a thread pool with the function func, at most max_threads may
    51  * run at a time (max_threads == -1 means no limit), exclusive == TRUE
    52  * means, that the threads shouldn't be shared and that they will be
    53  * prestarted (otherwise they are started as needed) user_data is the
    54  * 2nd argument to the func */
    55 IMPORT_C GThreadPool*    g_thread_pool_new             (GFunc            func,
    56                                                gpointer         user_data,
    57                                                gint             max_threads,
    58                                                gboolean         exclusive,
    59                                                GError         **error);
    60 
    61 /* Push new data into the thread pool. This task is assigned to a thread later
    62  * (when the maximal number of threads is reached for that pool) or now
    63  * (otherwise). If necessary a new thread will be started. The function
    64  * returns immediatly */
    65 IMPORT_C void            g_thread_pool_push            (GThreadPool     *pool,
    66                                                gpointer         data,
    67                                                GError         **error);
    68 
    69 /* Set the number of threads, which can run concurrently for that pool, -1
    70  * means no limit. 0 means has the effect, that the pool won't process
    71  * requests until the limit is set higher again */
    72 IMPORT_C void            g_thread_pool_set_max_threads (GThreadPool     *pool,
    73                                                gint             max_threads,
    74                                                GError         **error);
    75 IMPORT_C gint            g_thread_pool_get_max_threads (GThreadPool     *pool);
    76 
    77 /* Get the number of threads assigned to that pool. This number doesn't
    78  * necessarily represent the number of working threads in that pool */
    79 IMPORT_C guint           g_thread_pool_get_num_threads (GThreadPool     *pool);
    80 
    81 /* Get the number of unprocessed items in the pool */
    82 IMPORT_C guint           g_thread_pool_unprocessed     (GThreadPool     *pool);
    83 
    84 /* Free the pool, immediate means, that all unprocessed items in the queue
    85  * wont be processed, wait means, that the function doesn't return immediatly,
    86  * but after all threads in the pool are ready processing items. immediate
    87  * does however not mean, that threads are killed. */
    88 IMPORT_C void            g_thread_pool_free            (GThreadPool     *pool,
    89                                                gboolean         immediate,
    90                                                gboolean         wait);
    91 
    92 /* Set the maximal number of unused threads before threads will be stopped by
    93  * GLib, -1 means no limit */
    94 IMPORT_C void            g_thread_pool_set_max_unused_threads (gint      max_threads);
    95 IMPORT_C gint            g_thread_pool_get_max_unused_threads (void);
    96 IMPORT_C guint           g_thread_pool_get_num_unused_threads (void);
    97 
    98 /* Stop all currently unused threads, but leave the limit untouched */
    99 IMPORT_C void            g_thread_pool_stop_unused_threads    (void);
   100 
   101 /* Set sort function for priority threading */
   102 IMPORT_C void            g_thread_pool_set_sort_function      (GThreadPool      *pool,
   103 		                                      GCompareDataFunc  func,
   104 						      gpointer          user_data);
   105 
   106 /* Set maximum time a thread can be idle in the pool before it is stopped */
   107 IMPORT_C void            g_thread_pool_set_max_idle_time      (guint             interval);
   108 IMPORT_C guint           g_thread_pool_get_max_idle_time      (void);
   109 
   110 G_END_DECLS
   111 
   112 #endif /* __G_THREADPOOL_H__ */
   113