+guint g_spaced_primes_closest (guint num) G_GNUC_CONST;
+
+
+/* GIOChannel
+ */
+
+typedef struct _GIOFuncs GIOFuncs;
+typedef enum
+{
+ G_IO_ERROR_NONE,
+ G_IO_ERROR_AGAIN,
+ G_IO_ERROR_INVAL,
+ G_IO_ERROR_UNKNOWN
+} GIOError;
+typedef enum
+{
+ G_SEEK_CUR,
+ G_SEEK_SET,
+ G_SEEK_END
+} GSeekType;
+typedef enum
+{
+ G_IO_IN GLIB_SYSDEF_POLLIN,
+ G_IO_OUT GLIB_SYSDEF_POLLOUT,
+ G_IO_PRI GLIB_SYSDEF_POLLPRI,
+ G_IO_ERR GLIB_SYSDEF_POLLERR,
+ G_IO_HUP GLIB_SYSDEF_POLLHUP,
+ G_IO_NVAL GLIB_SYSDEF_POLLNVAL
+} GIOCondition;
+
+struct _GIOChannel
+{
+ guint channel_flags;
+ guint ref_count;
+ GIOFuncs *funcs;
+};
+
+typedef gboolean (*GIOFunc) (GIOChannel *source,
+ GIOCondition condition,
+ gpointer data);
+struct _GIOFuncs
+{
+ GIOError (*io_read) (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_read);
+ GIOError (*io_write) (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_written);
+ GIOError (*io_seek) (GIOChannel *channel,
+ gint offset,
+ GSeekType type);
+ void (*io_close) (GIOChannel *channel);
+ guint (*io_add_watch) (GIOChannel *channel,
+ gint priority,
+ GIOCondition condition,
+ GIOFunc func,
+ gpointer user_data,
+ GDestroyNotify notify);
+ void (*io_free) (GIOChannel *channel);
+};
+
+void g_io_channel_init (GIOChannel *channel);
+void g_io_channel_ref (GIOChannel *channel);
+void g_io_channel_unref (GIOChannel *channel);
+GIOError g_io_channel_read (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_read);
+GIOError g_io_channel_write (GIOChannel *channel,
+ gchar *buf,
+ guint count,
+ guint *bytes_written);
+GIOError g_io_channel_seek (GIOChannel *channel,
+ gint offset,
+ GSeekType type);
+void g_io_channel_close (GIOChannel *channel);
+guint g_io_add_watch_full (GIOChannel *channel,
+ gint priority,
+ GIOCondition condition,
+ GIOFunc func,
+ gpointer user_data,
+ GDestroyNotify notify);
+guint g_io_add_watch (GIOChannel *channel,
+ GIOCondition condition,
+ GIOFunc func,
+ gpointer user_data);
+
+
+/* Main loop
+ */
+typedef struct _GTimeVal GTimeVal;
+typedef struct _GSourceFuncs GSourceFuncs;
+typedef struct _GMainLoop GMainLoop; /* Opaque */
+
+struct _GTimeVal
+{
+ glong tv_sec;
+ glong tv_usec;
+};
+struct _GSourceFuncs
+{
+ gboolean (*prepare) (gpointer source_data,
+ GTimeVal *current_time,
+ gint *timeout,
+ gpointer user_data);
+ gboolean (*check) (gpointer source_data,
+ GTimeVal *current_time,
+ gpointer user_data);
+ gboolean (*dispatch) (gpointer source_data,
+ GTimeVal *dispatch_time,
+ gpointer user_data);
+ GDestroyNotify destroy;
+};
+
+/* Standard priorities */
+
+#define G_PRIORITY_HIGH -100
+#define G_PRIORITY_DEFAULT 0
+#define G_PRIORITY_HIGH_IDLE 100
+#define G_PRIORITY_DEFAULT_IDLE 200
+#define G_PRIORITY_LOW 300
+
+typedef gboolean (*GSourceFunc) (gpointer data);
+
+/* Hooks for adding to the main loop */
+guint g_source_add (gint priority,
+ gboolean can_recurse,
+ GSourceFuncs *funcs,
+ gpointer source_data,
+ gpointer user_data,
+ GDestroyNotify notify);
+gboolean g_source_remove (guint tag);
+gboolean g_source_remove_by_user_data (gpointer user_data);
+gboolean g_source_remove_by_source_data (gpointer source_data);
+gboolean g_source_remove_by_funcs_user_data (GSourceFuncs *funcs,
+ gpointer user_data);
+
+void g_get_current_time (GTimeVal *result);
+
+/* Running the main loop */
+GMainLoop* g_main_new (gboolean is_running);
+void g_main_run (GMainLoop *loop);
+void g_main_quit (GMainLoop *loop);
+void g_main_destroy (GMainLoop *loop);
+gboolean g_main_is_running (GMainLoop *loop);
+
+/* Run a single iteration of the mainloop. If block is FALSE,
+ * will never block
+ */
+gboolean g_main_iteration (gboolean may_block);
+
+/* See if any events are pending */
+gboolean g_main_pending (void);
+
+/* Idles and timeouts */
+guint g_timeout_add_full (gint priority,
+ guint interval,
+ GSourceFunc function,
+ gpointer data,
+ GDestroyNotify notify);
+guint g_timeout_add (guint interval,
+ GSourceFunc function,
+ gpointer data);
+guint g_idle_add (GSourceFunc function,
+ gpointer data);
+guint g_idle_add_full (gint priority,
+ GSourceFunc function,
+ gpointer data,
+ GDestroyNotify destroy);
+gboolean g_idle_remove_by_data (gpointer data);
+
+/* GPollFD
+ *
+ * System-specific IO and main loop calls
+ *
+ * On Win32, the fd in a GPollFD should be Win32 HANDLE (*not* a file
+ * descriptor as provided by the C runtime) that can be used by
+ * MsgWaitForMultipleObjects. This does *not* include file handles
+ * from CreateFile, SOCKETs, nor pipe handles. (But you can use
+ * WSAEventSelect to signal events when a SOCKET is readable).
+ *
+ * On Win32, fd can also be the special value G_WIN32_MSG_HANDLE to
+ * indicate polling for messages. These message queue GPollFDs should
+ * be added with the g_main_poll_win32_msg_add function.
+ *
+ * But note that G_WIN32_MSG_HANDLE GPollFDs should not be used by GDK
+ * (GTK) programs, as GDK itself wants to read messages and convert them
+ * to GDK events.
+ *
+ * So, unless you really know what you are doing, it's best not to try
+ * to use the main loop polling stuff for your own needs on
+ * Win32. It's really only written for the GIMP's needs so
+ * far.
+ */
+
+typedef struct _GPollFD GPollFD;
+typedef gint (*GPollFunc) (GPollFD *ufds,
+ guint nfsd,
+ gint timeout);
+struct _GPollFD
+{
+ gint fd;
+ gushort events;
+ gushort revents;
+};
+
+void g_main_add_poll (GPollFD *fd,
+ gint priority);
+void g_main_remove_poll (GPollFD *fd);
+void g_main_set_poll_func (GPollFunc func);
+
+#ifdef G_OS_WIN32
+
+/* Useful on other platforms, too? */
+
+GPollFunc g_main_win32_get_poll_func (void);
+
+#endif
+
+/* On Unix, IO channels created with this function for any file
+ * descriptor or socket.
+ *
+ * On Win32, use this only for files opened with the MSVCRT (the
+ * Microsoft run-time C library) _open() or _pipe, including file
+ * descriptors 0, 1 and 2 (corresponding to stdin, stdout and stderr).
+ *
+ * The term file descriptor as used in the context of Win32 refers to
+ * the emulated Unix-like file descriptors MSVCRT provides. The native
+ * corresponding concept is file HANDLE. There isn't as of yet a way to
+ * get GIOChannels for file HANDLEs.
+ */
+GIOChannel* g_io_channel_unix_new (int fd);
+gint g_io_channel_unix_get_fd (GIOChannel *channel);
+
+#ifdef G_OS_WIN32
+
+#define G_WIN32_MSG_HANDLE 19981206
+
+/* Use this to get a GPollFD from a GIOChannel, so that you can call
+ * g_io_channel_win32_poll(). After calling this you should only use
+ * g_io_channel_read() to read from the GIOChannel, i.e. never read()
+ * or recv() from the underlying file descriptor or SOCKET.
+ */
+void g_io_channel_win32_make_pollfd (GIOChannel *channel,
+ GIOCondition condition,
+ GPollFD *fd);
+
+/* This can be used to wait a until at least one of the channels is readable.
+ * On Unix you would do a select() on the file descriptors of the channels.
+ * This should probably be available for all platforms?
+ */
+gint g_io_channel_win32_poll (GPollFD *fds,
+ gint n_fds,
+ gint timeout);
+
+/* This is used to add polling for Windows messages. GDK (GTk+) programs
+ * should *not* use this.
+ */
+void g_main_poll_win32_msg_add (gint priority,
+ GPollFD *fd,
+ guint hwnd);
+
+/* An IO channel for Windows messages for window handle hwnd. */
+GIOChannel *g_io_channel_win32_new_messages (guint hwnd);
+
+/* An IO channel for C runtime (emulated Unix-like) file
+ * descriptors. Identical to g_io_channel_unix_new above.
+ * After calling g_io_add_watch() on a IO channel returned
+ * by this function, you shouldn't call read() on the file
+ * descriptor.
+ */
+GIOChannel* g_io_channel_win32_new_fd (int fd);
+
+/* Get the C runtime file descriptor of a channel. */
+gint g_io_channel_win32_get_fd (GIOChannel *channel);
+
+/* An IO channel for a SOCK_STREAM winsock socket. The parameter
+ * should be a SOCKET. After calling g_io_add_watch() on a IO channel
+ * returned by this function, you shouldn't call recv() on the SOCKET.
+ */
+GIOChannel *g_io_channel_win32_new_stream_socket (int socket);
+
+#endif
+
+/* Windows emulation stubs for common Unix functions
+ */
+#ifdef G_OS_WIN32
+# define MAXPATHLEN 1024
+
+#ifdef _MSC_VER
+typedef int pid_t;
+#endif
+
+/*
+ * To get prototypes for the following POSIXish functions, you have to
+ * include the indicated non-POSIX headers. The functions are defined
+ * in OLDNAMES.LIB (MSVC) or -lmoldname-msvc (mingw32).
+ *
+ * getcwd: <direct.h> (MSVC), <io.h> (mingw32)
+ * getpid: <process.h>
+ * access: <io.h>
+ * unlink: <stdio.h> or <io.h>
+ * open, read, write, lseek, close: <io.h>
+ * rmdir: <direct.h>
+ * pipe: <direct.h>
+ */
+
+/* pipe is not in OLDNAMES.LIB or -lmoldname-msvc. */
+#define pipe(phandles) _pipe (phandles, 4096, _O_BINARY)
+
+/* For some POSIX functions that are not provided by the MS runtime,
+ * we provide emulators in glib, which are prefixed with g_win32_.
+ */
+# define ftruncate(fd, size) g_win32_ftruncate (fd, size)
+
+/* -lmingw32 also has emulations for these, but we need our own
+ * for MSVC anyhow, so we might aswell use them always.
+ */
+# define opendir g_win32_opendir
+# define readdir g_win32_readdir
+# define rewinddir g_win32_rewinddir
+# define closedir g_win32_closedir
+# define NAME_MAX 255
+
+struct DIR
+{
+ gchar *dir_name;
+ gboolean just_opened;
+ guint find_file_handle;
+ gpointer find_file_data;
+};
+typedef struct DIR DIR;
+struct dirent
+{
+ gchar d_name[NAME_MAX + 1];
+};
+/* emulation functions */
+extern int g_win32_ftruncate (gint f,
+ guint size);
+DIR* g_win32_opendir (const gchar *dirname);
+struct dirent* g_win32_readdir (DIR *dir);
+void g_win32_rewinddir (DIR *dir);
+gint g_win32_closedir (DIR *dir);
+
+/* The MS setlocale uses locale names of the form "English_United
+ * States.1252" etc. We want the Unixish standard form "en", "zh_TW"
+ * etc. This function gets the current thread locale from Windows and
+ * returns it as a string of the above form for use in forming file
+ * names etc. The returned string should be deallocated with g_free().
+ */
+gchar * g_win32_getlocale (void);
+
+/* Translate a Win32 error code (as returned by GetLastError()) into
+ * the corresponding message. The returned string should be deallocated
+ * with g_free().
+ */
+gchar * g_win32_error_message (gint error);
+
+#endif /* G_OS_WIN32 */
+
+
+/* GLib Thread support
+ */
+
+extern GQuark g_thread_error_quark();
+#define G_THREAD_ERROR g_thread_error_quark()
+
+typedef enum
+{
+ G_THREAD_ERROR_AGAIN /* Resource temporarily unavailable */
+} GThreadError;
+
+typedef void (*GThreadFunc) (gpointer value);
+
+typedef enum
+{
+ G_THREAD_PRIORITY_LOW,
+ G_THREAD_PRIORITY_NORMAL,
+ G_THREAD_PRIORITY_HIGH,
+ G_THREAD_PRIORITY_URGENT
+} GThreadPriority;
+
+typedef struct _GThread GThread;
+struct _GThread
+{
+ GThreadPriority priority;
+ gboolean bound;
+ gboolean joinable;
+};
+
+typedef struct _GMutex GMutex;
+typedef struct _GCond GCond;
+typedef struct _GPrivate GPrivate;
+typedef struct _GStaticPrivate GStaticPrivate;
+typedef struct _GAsyncQueue GAsyncQueue;
+typedef struct _GThreadPool GThreadPool;
+
+typedef struct _GThreadFunctions GThreadFunctions;
+struct _GThreadFunctions
+{
+ GMutex* (*mutex_new) (void);
+ void (*mutex_lock) (GMutex *mutex);
+ gboolean (*mutex_trylock) (GMutex *mutex);
+ void (*mutex_unlock) (GMutex *mutex);
+ void (*mutex_free) (GMutex *mutex);
+ GCond* (*cond_new) (void);
+ void (*cond_signal) (GCond *cond);
+ void (*cond_broadcast) (GCond *cond);
+ void (*cond_wait) (GCond *cond,
+ GMutex *mutex);
+ gboolean (*cond_timed_wait) (GCond *cond,
+ GMutex *mutex,
+ GTimeVal *end_time);
+ void (*cond_free) (GCond *cond);
+ GPrivate* (*private_new) (GDestroyNotify destructor);
+ gpointer (*private_get) (GPrivate *private_key);
+ void (*private_set) (GPrivate *private_key,
+ gpointer data);
+ void (*thread_create) (GThreadFunc thread_func,
+ gpointer arg,
+ gulong stack_size,
+ gboolean joinable,
+ gboolean bound,
+ GThreadPriority priority,
+ gpointer thread,
+ GError **error);
+ void (*thread_yield) (void);
+ void (*thread_join) (gpointer thread);
+ void (*thread_exit) (void);
+ void (*thread_set_priority)(gpointer thread,
+ GThreadPriority priority);
+ void (*thread_self) (gpointer thread);
+};
+
+GLIB_VAR GThreadFunctions g_thread_functions_for_glib_use;
+GLIB_VAR gboolean g_thread_use_default_impl;
+GLIB_VAR gboolean g_threads_got_initialized;
+
+/* initializes the mutex/cond/private implementation for glib, might
+ * only be called once, and must not be called directly or indirectly
+ * from another glib-function, e.g. as a callback.
+ */
+void g_thread_init (GThreadFunctions *vtable);
+
+/* internal function for fallback static mutex implementation */
+GMutex* g_static_mutex_get_mutex_impl (GMutex **mutex);
+
+/* shorthands for conditional and unconditional function calls */
+#define G_THREAD_UF(name, arglist) \
+ (*g_thread_functions_for_glib_use . name) arglist
+#define G_THREAD_CF(name, fail, arg) \
+ (g_thread_supported () ? G_THREAD_UF (name, arg) : (fail))
+/* keep in mind, all those mutexes and static mutexes are not
+ * recursive in general, don't rely on that
+ */
+#define g_thread_supported() (g_threads_got_initialized)
+#define g_mutex_new() G_THREAD_UF (mutex_new, ())
+#define g_mutex_lock(mutex) G_THREAD_CF (mutex_lock, (void)0, (mutex))
+#define g_mutex_trylock(mutex) G_THREAD_CF (mutex_trylock, TRUE, (mutex))
+#define g_mutex_unlock(mutex) G_THREAD_CF (mutex_unlock, (void)0, (mutex))
+#define g_mutex_free(mutex) G_THREAD_CF (mutex_free, (void)0, (mutex))
+#define g_cond_new() G_THREAD_UF (cond_new, ())
+#define g_cond_signal(cond) G_THREAD_CF (cond_signal, (void)0, (cond))
+#define g_cond_broadcast(cond) G_THREAD_CF (cond_broadcast, (void)0, (cond))
+#define g_cond_wait(cond, mutex) G_THREAD_CF (cond_wait, (void)0, (cond, \
+ mutex))
+#define g_cond_free(cond) G_THREAD_CF (cond_free, (void)0, (cond))
+#define g_cond_timed_wait(cond, mutex, abs_time) G_THREAD_CF (cond_timed_wait, \
+ TRUE, \
+ (cond, mutex, \
+ abs_time))
+#define g_private_new(destructor) G_THREAD_UF (private_new, (destructor))
+#define g_private_get(private_key) G_THREAD_CF (private_get, \
+ ((gpointer)private_key), \
+ (private_key))
+#define g_private_set(private_key, value) G_THREAD_CF (private_set, \
+ (void) (private_key = \
+ (GPrivate*) (value)), \
+ (private_key, value))
+#define g_thread_yield() G_THREAD_CF (thread_yield, (void)0, ())
+#define g_thread_exit() G_THREAD_CF (thread_exit, (void)0, ())
+
+GThread* g_thread_create (GThreadFunc thread_func,
+ gpointer arg,
+ gulong stack_size,
+ gboolean joinable,
+ gboolean bound,
+ GThreadPriority priority,
+ GError **error);
+GThread* g_thread_self ();
+void g_thread_join (GThread *thread);
+void g_thread_set_priority (GThread *thread,
+ GThreadPriority priority);
+
+/* GStaticMutexes can be statically initialized with the value
+ * G_STATIC_MUTEX_INIT, and then they can directly be used, that is
+ * much easier, than having to explicitly allocate the mutex before
+ * use
+ */
+#define g_static_mutex_lock(mutex) \
+ g_mutex_lock (g_static_mutex_get_mutex (mutex))
+#define g_static_mutex_trylock(mutex) \
+ g_mutex_trylock (g_static_mutex_get_mutex (mutex))
+#define g_static_mutex_unlock(mutex) \
+ g_mutex_unlock (g_static_mutex_get_mutex (mutex))
+
+struct _GStaticPrivate
+{
+ guint index;
+};
+#define G_STATIC_PRIVATE_INIT { 0 }
+gpointer g_static_private_get (GStaticPrivate *private_key);
+void g_static_private_set (GStaticPrivate *private_key,
+ gpointer data,
+ GDestroyNotify notify);
+gpointer g_static_private_get_for_thread (GStaticPrivate *private_key,
+ GThread *thread);
+void g_static_private_set_for_thread (GStaticPrivate *private_key,
+ GThread *thread,
+ gpointer data,
+ GDestroyNotify notify);
+
+typedef struct _GStaticRecMutex GStaticRecMutex;
+struct _GStaticRecMutex
+{
+ GStaticMutex mutex;
+ unsigned int depth;
+ GSystemThread owner;
+};
+
+#define G_STATIC_REC_MUTEX_INIT { G_STATIC_MUTEX_INIT }
+void g_static_rec_mutex_lock (GStaticRecMutex *mutex);
+gboolean g_static_rec_mutex_trylock (GStaticRecMutex *mutex);
+void g_static_rec_mutex_unlock (GStaticRecMutex *mutex);
+void g_static_rec_mutex_lock_full (GStaticRecMutex *mutex,
+ guint depth);
+guint g_static_rec_mutex_unlock_full (GStaticRecMutex *mutex);
+
+typedef struct _GStaticRWLock GStaticRWLock;
+struct _GStaticRWLock
+{
+ GStaticMutex mutex;
+ GCond *read_cond;
+ GCond *write_cond;
+ guint read_counter;
+ gboolean write;
+ guint want_to_write;
+};
+
+#define G_STATIC_RW_LOCK_INIT { G_STATIC_MUTEX_INIT, NULL, NULL, 0, FALSE, FALSE }
+
+void g_static_rw_lock_reader_lock (GStaticRWLock* lock);
+gboolean g_static_rw_lock_reader_trylock (GStaticRWLock* lock);
+void g_static_rw_lock_reader_unlock (GStaticRWLock* lock);
+void g_static_rw_lock_writer_lock (GStaticRWLock* lock);
+gboolean g_static_rw_lock_writer_trylock (GStaticRWLock* lock);
+void g_static_rw_lock_writer_unlock (GStaticRWLock* lock);
+void g_static_rw_lock_free (GStaticRWLock* lock);
+
+/* these are some convenience macros that expand to nothing if GLib
+ * was configured with --disable-threads. for using StaticMutexes,
+ * you define them with G_LOCK_DEFINE_STATIC (name) or G_LOCK_DEFINE (name)
+ * if you need to export the mutex. With G_LOCK_EXTERN (name) you can
+ * declare such an globally defined lock. name is a unique identifier
+ * for the protected varibale or code portion. locking, testing and
+ * unlocking of such mutexes can be done with G_LOCK(), G_UNLOCK() and
+ * G_TRYLOCK() respectively.
+ */
+extern void glib_dummy_decl (void);
+#define G_LOCK_NAME(name) g__ ## name ## _lock
+#ifdef G_THREADS_ENABLED
+# define G_LOCK_DEFINE_STATIC(name) static G_LOCK_DEFINE (name)
+# define G_LOCK_DEFINE(name) \
+ GStaticMutex G_LOCK_NAME (name) = G_STATIC_MUTEX_INIT
+# define G_LOCK_EXTERN(name) extern GStaticMutex G_LOCK_NAME (name)
+
+# ifdef G_DEBUG_LOCKS
+# define G_LOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): locking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ g_static_mutex_lock (&G_LOCK_NAME (name)); \
+ }G_STMT_END
+# define G_UNLOCK(name) G_STMT_START{ \
+ g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): unlocking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name); \
+ g_static_mutex_unlock (&G_LOCK_NAME (name)); \
+ }G_STMT_END
+# define G_TRYLOCK(name) \
+ (g_log (G_LOG_DOMAIN, G_LOG_LEVEL_DEBUG, \
+ "file %s: line %d (%s): try locking: %s ", \
+ __FILE__, __LINE__, G_GNUC_PRETTY_FUNCTION, \
+ #name), g_static_mutex_trylock (&G_LOCK_NAME (name)))
+# else /* !G_DEBUG_LOCKS */
+# define G_LOCK(name) g_static_mutex_lock (&G_LOCK_NAME (name))
+# define G_UNLOCK(name) g_static_mutex_unlock (&G_LOCK_NAME (name))
+# define G_TRYLOCK(name) g_static_mutex_trylock (&G_LOCK_NAME (name))
+# endif /* !G_DEBUG_LOCKS */
+#else /* !G_THREADS_ENABLED */
+# define G_LOCK_DEFINE_STATIC(name) extern void glib_dummy_decl (void)
+# define G_LOCK_DEFINE(name) extern void glib_dummy_decl (void)
+# define G_LOCK_EXTERN(name) extern void glib_dummy_decl (void)
+# define G_LOCK(name)
+# define G_UNLOCK(name)
+# define G_TRYLOCK(name) (TRUE)
+#endif /* !G_THREADS_ENABLED */
+
+/* Asyncronous Queues, can be used to communicate between threads
+ */
+
+/* Get a new GAsyncQueue with the ref_count 1 */
+GAsyncQueue* g_async_queue_new (void);
+
+/* Lock and unlock an GAsyncQueue, all functions lock the queue for
+ * themselves, but in certain cirumstances you want to hold the lock longer,
+ * thus you lock the queue, call the *_unlocked functions and unlock it again
+ */
+void g_async_queue_lock (GAsyncQueue *queue);
+void g_async_queue_unlock (GAsyncQueue *queue);
+
+/* Ref and unref the GAsyncQueue. g_async_queue_unref_unlocked makes
+ * no sense, as after the unreffing the Queue might be gone and can't
+ * be unlocked. So you have a function to call, if you don't hold the
+ * lock (g_async_queue_unref) and one to call, when you already hold
+ * the lock (g_async_queue_unref_and_unlock). After that however, you
+ * don't hold the lock anymore and the Queue might in fact be
+ * destroyed, if you unrefed to zero */
+void g_async_queue_ref (GAsyncQueue *queue);
+void g_async_queue_ref_unlocked (GAsyncQueue *queue);
+void g_async_queue_unref (GAsyncQueue *queue);
+void g_async_queue_unref_and_unlock (GAsyncQueue *queue);
+
+/* Push data into the async queue. Must not be NULL */
+void g_async_queue_push (GAsyncQueue *queue,
+ gpointer data);
+void g_async_queue_push_unlocked (GAsyncQueue *queue,
+ gpointer data);
+
+/* Pop data from the async queue, when no data is there, the thread is blocked
+ * until data arrives */
+gpointer g_async_queue_pop (GAsyncQueue *queue);
+gpointer g_async_queue_pop_unlocked (GAsyncQueue *queue);
+
+/* Try to pop data, NULL is returned in case of empty queue */
+gpointer g_async_queue_try_pop (GAsyncQueue *queue);
+gpointer g_async_queue_try_pop_unlocked (GAsyncQueue *queue);
+
+/* Wait for data until at maximum until end_time is reached, NULL is returned
+ * in case of empty queue*/
+gpointer g_async_queue_timed_pop (GAsyncQueue *queue,
+ GTimeVal *end_time);
+gpointer g_async_queue_timed_pop_unlocked (GAsyncQueue *queue,
+ GTimeVal *end_time);
+
+/* Return the length of the queue, negative values mean, that threads
+ * are waiting, positve values mean, that there are entries in the
+ * queue. Actually this function returns the length of the queue minus
+ * the number of waiting threads, g_async_queue_length == 0 could also
+ * mean 'n' entries in the queue and 'n' thread waiting, such can
+ * happen due to locking of the queue or due to scheduling. */
+gint g_async_queue_length (GAsyncQueue *queue);
+gint g_async_queue_length_unlocked (GAsyncQueue *queue);
+
+/* Thread Pools
+ */
+
+/* The real GThreadPool is bigger, so you may only create a thread
+ * pool with the constructor function */
+struct _GThreadPool
+{
+ GFunc thread_func;
+ gulong stack_size;
+ gboolean bound;
+ GThreadPriority priority;
+ gboolean exclusive;
+ gpointer user_data;
+};
+
+/* Get a thread pool with the function thread_func, at most max_threads may
+ * run at a time (max_threads == -1 means no limit), stack_size, bound,
+ * priority like in g_thread_create, exclusive == TRUE means, that the threads
+ * shouldn't be shared and that they will be prestarted (otherwise they are
+ * started, as needed) user_data is the 2nd argument to the thread_func */
+GThreadPool* g_thread_pool_new (GFunc thread_func,
+ gint max_threads,
+ gulong stack_size,
+ gboolean bound,
+ GThreadPriority priority,
+ gboolean exclusive,
+ gpointer user_data,
+ GError **error);
+
+/* Push new data into the thread pool. This task is assigned to a thread later
+ * (when the maximal number of threads is reached for that pool) or now
+ * (otherwise). If necessary a new thread will be started. The function
+ * returns immediatly */
+void g_thread_pool_push (GThreadPool *pool,
+ gpointer data,
+ GError **error);
+
+/* Set the number of threads, which can run concurrently for that pool, -1
+ * means no limit. 0 means has the effect, that the pool won't process
+ * requests until the limit is set higher again */
+void g_thread_pool_set_max_threads (GThreadPool *pool,
+ gint max_threads,
+ GError **error);
+gint g_thread_pool_get_max_threads (GThreadPool *pool);
+
+/* Get the number of threads assigned to that pool. This number doesn't
+ * necessarily represent the number of working threads in that pool */
+guint g_thread_pool_get_num_threads (GThreadPool *pool);
+
+/* Get the number of unprocessed items in the pool */
+guint g_thread_pool_unprocessed (GThreadPool *pool);
+
+/* Free the pool, immediate means, that all unprocessed items in the queue
+ * wont be processed, wait means, that the function doesn't return immediatly,
+ * but after all threads in the pool are ready processing items. immediate
+ * does however not mean, that threads are killed. */
+void g_thread_pool_free (GThreadPool *pool,
+ gboolean immediate,
+ gboolean wait);
+
+/* Set the maximal number of unused threads before threads will be stopped by
+ * GLib, -1 means no limit */
+void g_thread_pool_set_max_unused_threads (gint max_threads);
+gint g_thread_pool_get_max_unused_threads (void);
+guint g_thread_pool_get_num_unused_threads (void);
+
+/* Stop all currently unused threads, but leave the limit untouched */
+void g_thread_pool_stop_unused_threads (void);
+
+typedef enum
+{
+ G_CONVERT_ERROR_NO_CONVERSION,
+ G_CONVERT_ERROR_ILLEGAL_SEQUENCE,
+ G_CONVERT_ERROR_OTHER
+} GConvertError;
+
+#define G_CONVERT_ERROR g_convert_error_quark()
+GQuark g_convert_error_quark();
+
+gchar* g_convert (const gchar *str,
+ gint len,
+ const gchar *to_codeset,
+ const gchar *from_codeset,
+ gint *bytes_read,
+ gint *bytes_written,
+ GError **error);
+gchar* g_convert_with_fallback (const gchar *str,
+ gint len,
+ const gchar *to_codeset,
+ const gchar *from_codeset,
+ gchar *fallback,
+ gint *bytes_read,
+ gint *bytes_written,
+ GError **error);