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