Debian Codegraph @

gstreamer/src/taskpool.hg

raw
1 /* gstreamermm - a C++ wrapper for gstreamer
2 *
3 * Copyright 2008-2009 The gstreamermm Development Team
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free
17 * Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
18 */
19
20 #include <gst/gst.h>
21 #include <gstreamermm/object.h>
22
23 _DEFS(gstreamermm,gst)
24
25 namespace Gst
26 {
27
28 /** A class representing a pool of GStreamer streaming threads.
29 * This object provides an abstraction for creating threads. The default
30 * implementation uses a regular Glib::ThreadPool to start tasks.
31 *
32 * Subclasses can be made to create custom threads.
33 *
34 * Last reviewed on 2009-04-23 (0.10.24)
35 */
36 class TaskPool : public Object
37 {
38 _CLASS_GOBJECT(TaskPool, GstTaskPool, GST_TASK_POOL, Object, GstObject)
39
40 protected:
41 _CTOR_DEFAULT()
42
43 public:
44 /** For example,
45 * void on_do_push();.
46 */
47 typedef sigc::slot<void> SlotPush;
48
49 public:
50 /** Create a new default task pool. The default task pool will use a regular
51 * Glib::ThreadPool for threads.
52 * @return A new Gst::TaskPool.
53 */
54 _WRAP_CREATE()
55
56 /** @throw Glib::Error.
57 */
58 _WRAP_METHOD(void prepare(), gst_task_pool_prepare, errthrow)
59
60 /** Start the execution of a new thread from pool.
61 *
62 * @param slot The function to call.
63 * @return A pointer that should be used for the join() method. This pointer
64 * can be 0, you must check error to detect errors.
65 * @throw Glib::Error.
66 */
67 gpointer push(const SlotPush& slot);
68 _IGNORE(gst_task_pool_push)
69
70 _WRAP_METHOD(void join(gpointer id), gst_task_pool_join)
71 _WRAP_METHOD(void cleanup(), gst_task_pool_cleanup)
72
73 /** Virtual function which prepares the thread pool.
74 * @throw Glib::Error.
75 */
76 virtual void prepare_vfunc();
77
78 /** Virtual function to cleanup the thread pool.
79 */
80 _WRAP_VFUNC(void cleanup(), "cleanup")
81
82 /** Virtual function which starts a new thread.
83 * @throw Glib::Error.
84 */
85 virtual gpointer push_vfunc(const SlotPush& slot);
86
87 /** Virtual function to join a thread.
88 */
89 _WRAP_VFUNC(void join(gpointer id), "join")
90
91 protected:
92 #m4begin
93 _PUSH(SECTION_PCC_CLASS_INIT_VFUNCS)
94 klass->prepare = &prepare_vfunc_callback;
95 klass->push = &push_vfunc_callback;
96 _SECTION(SECTION_PH_VFUNCS)
97 static void prepare_vfunc_callback(GstTaskPool* self, GError** error);
98 static gpointer push_vfunc_callback(GstTaskPool* self,
99 GstTaskPoolFunction func, gpointer user_data, GError** error);
100 _POP()
101 #m4end
102 };
103
104 } // namespace Gst