GAsyncQueue: Move private API to a private header

This commit is contained in:
Matthias Clasen 2011-10-01 18:42:48 -04:00
parent b17b02da79
commit 93abf20d3b
5 changed files with 48 additions and 15 deletions

View File

@ -122,6 +122,7 @@ libglib_2_0_la_SOURCES = \
glib_probes.d \
garray.c \
gasyncqueue.c \
gasyncqueueprivate.h \
gatomic.c \
gbacktrace.c \
gbase64.c \
@ -178,9 +179,9 @@ libglib_2_0_la_SOURCES = \
gstrfuncs.c \
gstring.c \
gtestutils.c \
gthread.c \
gthread.c \
gthreadprivate.h \
gthreadpool.c \
gthreadpool.c \
gtimer.c \
gtimezone.c \
gtree.c \

View File

@ -27,6 +27,7 @@
#include "config.h"
#include "gasyncqueue.h"
#include "gasyncqueueprivate.h"
#include "gmem.h"
#include "gqueue.h"

View File

@ -112,9 +112,6 @@ void g_async_queue_sort_unlocked (GAsyncQueue *queue,
GCompareDataFunc func,
gpointer user_data);
/* Private API */
GMutex* _g_async_queue_get_mutex (GAsyncQueue *queue);
G_END_DECLS
#endif /* __G_ASYNCQUEUE_H__ */

31
glib/gasyncqueueprivate.h Normal file
View File

@ -0,0 +1,31 @@
/* GLIB - Library of useful routines for C programming
* Copyright (C) 1995-1997 Peter Mattis, Spencer Kimball and Josh MacDonald
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the
* Free Software Foundation, Inc., 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*/
#ifndef __G_ASYNCQUEUEPRIVATE_H__
#define __G_ASYNCQUEUEPRIVATE_H__
#include "gasyncqueue.h"
G_BEGIN_DECLS
GMutex *_g_async_queue_get_mutex (GAsyncQueue *queue);
G_END_DECLS
#endif /* __G_ASYNCQUEUEPRIVATE_H__ */

View File

@ -29,6 +29,7 @@
#include "gthreadpool.h"
#include "gasyncqueue.h"
#include "gasyncqueueprivate.h"
#include "gmain.h"
#include "gtestutils.h"
#include "gtimer.h"
@ -88,7 +89,7 @@ typedef struct _GRealThreadPool GRealThreadPool;
struct _GRealThreadPool
{
GThreadPool pool;
GAsyncQueue* queue;
GAsyncQueue *queue;
GCond *cond;
gint max_threads;
gint num_threads;
@ -175,8 +176,7 @@ g_thread_pool_wait_for_new_pool (void)
else
{
/* If no maximal idle time is given, wait indefinitely. */
DEBUG_MSG (("thread %p waiting in global pool.",
g_thread_self ()));
DEBUG_MSG (("thread %p waiting in global pool.", g_thread_self ()));
pool = g_async_queue_pop (unused_thread_queue);
}
@ -489,6 +489,8 @@ g_thread_pool_new (GFunc func,
retval->max_threads = max_threads;
retval->num_threads = 0;
retval->running = TRUE;
retval->immediate = FALSE;
retval->waiting = FALSE;
retval->sort_func = NULL;
retval->sort_user_data = NULL;
@ -524,12 +526,13 @@ g_thread_pool_new (GFunc func,
* @data: a new task for @pool
* @error: return location for error, or %NULL
*
* Inserts @data into the list of tasks to be executed by @pool. When
* the number of currently running threads is lower than the maximal
* allowed number of threads, a new thread is started (or reused) with
* the properties given to g_thread_pool_new (). Otherwise @data stays
* in the queue until a thread in this pool finishes its previous task
* and processes @data.
* Inserts @data into the list of tasks to be executed by @pool.
*
* When the number of currently running threads is lower than the
* maximal allowed number of threads, a new thread is started (or
* reused) with the properties given to g_thread_pool_new().
* Otherwise, @data stays in the queue until a thread in this pool
* finishes its previous task and processes @data.
*
* @error can be %NULL to ignore errors, or non-%NULL to report
* errors. An error can only occur when a new thread couldn't be
@ -735,7 +738,7 @@ g_thread_pool_unprocessed (GThreadPool *pool)
*
* If @immediate is %TRUE, no new task is processed for @pool.
* Otherwise @pool is not freed before the last task is processed.
* Note however, that no thread of this pool is interrupted, while
* Note however, that no thread of this pool is interrupted while
* processing a task. Instead at least all still running threads
* can finish their tasks before the @pool is freed.
*