taskpool: fix docs, make push/join generic

Fix some more docs.
Make _push() return a generic id (this can be something else than a GThread in
some cases) and make _join() use that generic id.
This commit is contained in:
Wim Taymans 2009-04-23 16:00:56 +02:00 committed by Wim Taymans
parent aadac11ae3
commit 4d326be6cf
3 changed files with 19 additions and 15 deletions

View file

@ -2176,8 +2176,8 @@ GstTaskPoolClass
gst_task_pool_new gst_task_pool_new
gst_task_pool_set_func gst_task_pool_set_func
gst_task_pool_prepare gst_task_pool_prepare
gst_task_pool_join
gst_task_pool_push gst_task_pool_push
gst_task_pool_join
gst_task_pool_cleanup gst_task_pool_cleanup
<SUBSECTION Standard> <SUBSECTION Standard>
GST_IS_TASK_POOL GST_IS_TASK_POOL

View file

@ -74,7 +74,7 @@ default_cleanup (GstTaskPool * pool)
GST_OBJECT_UNLOCK (pool); GST_OBJECT_UNLOCK (pool);
} }
static GThread * static gpointer
default_push (GstTaskPool * pool, gpointer data, GError ** error) default_push (GstTaskPool * pool, gpointer data, GError ** error)
{ {
GST_OBJECT_LOCK (pool); GST_OBJECT_LOCK (pool);
@ -86,7 +86,7 @@ default_push (GstTaskPool * pool, gpointer data, GError ** error)
} }
static void static void
default_join (GstTaskPool * pool, GThread * thread) default_join (GstTaskPool * pool, gpointer id)
{ {
/* does nothing, we can't join for threads from the threadpool */ /* does nothing, we can't join for threads from the threadpool */
} }
@ -203,10 +203,11 @@ gst_task_pool_cleanup (GstTaskPool * pool)
* *
* Start the execution of a new thread from @pool. * Start the execution of a new thread from @pool.
* *
* Returns: a #GThread or NULL when the GThread is not yet known. You must check * Returns: a pointer that should be used for the gst_task_pool_join
* @error to detect errors. * function. This pointer can be NULL, you must check @error to detect
* errors.
*/ */
GThread * gpointer
gst_task_pool_push (GstTaskPool * pool, gpointer data, GError ** error) gst_task_pool_push (GstTaskPool * pool, gpointer data, GError ** error)
{ {
GstTaskPoolClass *klass; GstTaskPoolClass *klass;
@ -231,12 +232,13 @@ not_supported:
/** /**
* gst_task_pool_join: * gst_task_pool_join:
* @pool: a #GstTaskPool * @pool: a #GstTaskPool
* @thread: a #GThread * @id: the id
* *
* Join a GThread or return it to the pool. * Join a task and/or return it to the pool. @id is the id obtained from
* gst_task_pool_push().
*/ */
void void
gst_task_pool_join (GstTaskPool * pool, GThread * thread) gst_task_pool_join (GstTaskPool * pool, gpointer id)
{ {
GstTaskPoolClass *klass; GstTaskPoolClass *klass;
@ -245,5 +247,5 @@ gst_task_pool_join (GstTaskPool * pool, GThread * thread)
klass = GST_TASK_POOL_GET_CLASS (pool); klass = GST_TASK_POOL_GET_CLASS (pool);
if (klass->join) if (klass->join)
klass->join (pool, thread); klass->join (pool, id);
} }

View file

@ -57,7 +57,8 @@ struct _GstTaskPool {
/** /**
* GstTaskPoolClass: * GstTaskPoolClass:
* @init: initialize the threadpool * @parent_class: the parent class structure
* @prepare: prepare the threadpool
* @cleanup: make sure all threads are stopped * @cleanup: make sure all threads are stopped
* @push: start a new thread * @push: start a new thread
* @join: join a thread * @join: join a thread
@ -67,12 +68,13 @@ struct _GstTaskPool {
struct _GstTaskPoolClass { struct _GstTaskPoolClass {
GstObjectClass parent_class; GstObjectClass parent_class;
/*< public >*/
void (*prepare) (GstTaskPool *pool, GFunc func, void (*prepare) (GstTaskPool *pool, GFunc func,
gpointer user_data, GError **error); gpointer user_data, GError **error);
void (*cleanup) (GstTaskPool *pool); void (*cleanup) (GstTaskPool *pool);
GThread * (*push) (GstTaskPool *pool, gpointer data, GError **error); gpointer (*push) (GstTaskPool *pool, gpointer data, GError **error);
void (*join) (GstTaskPool *pool, GThread *thread); void (*join) (GstTaskPool *pool, gpointer id);
/*< private >*/ /*< private >*/
gpointer _gst_reserved[GST_PADDING]; gpointer _gst_reserved[GST_PADDING];
@ -87,9 +89,9 @@ void gst_task_pool_set_func (GstTaskPool *pool,
void gst_task_pool_prepare (GstTaskPool *pool, GError **error); void gst_task_pool_prepare (GstTaskPool *pool, GError **error);
GThread * gst_task_pool_push (GstTaskPool *pool, gpointer data, gpointer gst_task_pool_push (GstTaskPool *pool, gpointer data,
GError **error); GError **error);
void gst_task_pool_join (GstTaskPool *pool, GThread *thread); void gst_task_pool_join (GstTaskPool *pool, gpointer id);
void gst_task_pool_cleanup (GstTaskPool *pool); void gst_task_pool_cleanup (GstTaskPool *pool);