2 * Copyright (C) <2009> Wim Taymans <wim.taymans@gmail.com>
4 * gsttaskpool.h: Pool for creating streaming threads
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Library General Public
8 * License as published by the Free Software Foundation; either
9 * version 2 of the License, or (at your option) any later version.
11 * This library is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 * Library General Public License for more details.
16 * You should have received a copy of the GNU Library General Public
17 * License along with this library; if not, write to the
18 * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
19 * Boston, MA 02110-1301, USA.
22 #ifndef __GST_TASK_POOL_H__
23 #define __GST_TASK_POOL_H__
25 #include <gst/gstobject.h>
29 /* --- standard type macros --- */
30 #define GST_TYPE_TASK_POOL (gst_task_pool_get_type ())
31 #define GST_TASK_POOL(pool) (G_TYPE_CHECK_INSTANCE_CAST ((pool), GST_TYPE_TASK_POOL, GstTaskPool))
32 #define GST_IS_TASK_POOL(pool) (G_TYPE_CHECK_INSTANCE_TYPE ((pool), GST_TYPE_TASK_POOL))
33 #define GST_TASK_POOL_CLASS(pclass) (G_TYPE_CHECK_CLASS_CAST ((pclass), GST_TYPE_TASK_POOL, GstTaskPoolClass))
34 #define GST_IS_TASK_POOL_CLASS(pclass) (G_TYPE_CHECK_CLASS_TYPE ((pclass), GST_TYPE_TASK_POOL))
35 #define GST_TASK_POOL_GET_CLASS(pool) (G_TYPE_INSTANCE_GET_CLASS ((pool), GST_TYPE_TASK_POOL, GstTaskPoolClass))
36 #define GST_TASK_POOL_CAST(pool) ((GstTaskPool*)(pool))
38 typedef struct _GstTaskPool GstTaskPool;
39 typedef struct _GstTaskPoolClass GstTaskPoolClass;
42 * GstTaskPoolFunction:
43 * @user_data: user data for the task function
45 * Task function, see gst_task_pool_push().
47 typedef void (*GstTaskPoolFunction) (void *user_data);
52 * The #GstTaskPool object.
60 gpointer _gst_reserved[GST_PADDING];
65 * @parent_class: the parent class structure
66 * @prepare: prepare the threadpool
67 * @cleanup: make sure all threads are stopped
68 * @push: start a new thread
69 * @join: join a thread
71 * The #GstTaskPoolClass object.
73 struct _GstTaskPoolClass {
74 GstObjectClass parent_class;
77 void (*prepare) (GstTaskPool *pool, GError **error);
78 void (*cleanup) (GstTaskPool *pool);
80 gpointer (*push) (GstTaskPool *pool, GstTaskPoolFunction func,
81 gpointer user_data, GError **error);
82 void (*join) (GstTaskPool *pool, gpointer id);
85 gpointer _gst_reserved[GST_PADDING];
89 GType gst_task_pool_get_type (void);
92 GstTaskPool * gst_task_pool_new (void);
95 void gst_task_pool_prepare (GstTaskPool *pool, GError **error);
98 gpointer gst_task_pool_push (GstTaskPool *pool, GstTaskPoolFunction func,
99 gpointer user_data, GError **error);
101 void gst_task_pool_join (GstTaskPool *pool, gpointer id);
104 void gst_task_pool_cleanup (GstTaskPool *pool);
106 #ifdef G_DEFINE_AUTOPTR_CLEANUP_FUNC
107 G_DEFINE_AUTOPTR_CLEANUP_FUNC(GstTaskPool, gst_object_unref)
112 #endif /* __GST_TASK_POOL_H__ */